This commit is contained in:
xyj 2023-12-28 16:54:53 +08:00
parent a0e4dcac5b
commit de7f10bb0e
5 changed files with 28 additions and 9 deletions

View File

@ -1,5 +1,9 @@
# 每天00分执行 # 每天00分执行
0 0 * * * /usr/bin/python /home/pi/lot_manager/delete_lot_data_3_days.py 0 0 * * * /usr/bin/python /home/pi/lot_manager/delete_lot_data_3_days.py
# 每天0800分执行
0 8 * * * sudo /usr/bin/python /home/pi/lot_manager/open_led.py
# 每天1800分执行
0 18 * * * sudo /usr/bin/python /home/pi/lot_manager/close_led.py
# 针对32G内存卡的定时额外加这个 # 针对32G内存卡的定时额外加这个
# 每隔15分钟进行 # 每隔15分钟进行
*/15 * * * * /usr/bin/python /home/pi/lot_manager/delete_than20G.py */15 * * * * /usr/bin/python /home/pi/lot_manager/delete_than20G.py

View File

@ -2,4 +2,8 @@
# 每小时0分执行,32G的不用加 # 每小时0分执行,32G的不用加
0 * * * * /usr/bin/bash /home/pi/lot_manager/bash/cron_delete_mp4.sh 0 * * * * /usr/bin/bash /home/pi/lot_manager/bash/cron_delete_mp4.sh
# 每天00分执行 # 每天00分执行
0 0 * * * /usr/bin/python /home/pi/lot_manager/delete_lot_data_3_days.py 0 0 * * * /usr/bin/python /home/pi/lot_manager/delete_lot_data_3_days.py
# 每天0800分执行
0 8 * * * sudo /usr/bin/python /home/pi/lot_manager/open_led.py
# 每天1800分执行
0 18 * * * sudo /usr/bin/python /home/pi/lot_manager/close_led.py

8
cron_set.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
sudo crontab -l > cron.cron
echo "0 8 * * * sudo /usr/bin/python /home/pi/lot_manager/open_led.py" >> cron.cron
echo "0 18 * * * sudo /usr/bin/python /home/pi/lot_manager/close_led.py" >> cron.cron
sudo crontab cron.cron
sudo systemctl restart cron.service
sudo rm -rf cron.cron

View File

@ -10,11 +10,14 @@ git config --global user.name xyj
git config --global user.email 1090822794@qq.com git config --global user.email 1090822794@qq.com
git config --global credential.helper store git config --global credential.helper store
echo "0 8 * * * sudo /usr/bin/python /home/pi/lot_manager/open_led.py" >> sudo crontab -
echo "0 18 * * * sudo /usr/bin/python /home/pi/lot_manager/close_led.py" >> sudo crontab -
cd /home/pi cd /home/pi
git clone https://gitea.lihaink.cn/xyj/lot_manager.git git clone https://gitea.lihaink.cn/xyj/lot_manager.git
cd lot_manager cd lot_manager
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
sudo pip install Adafruit-Blinka
sudo cp /etc/supervisor/supervisord.conf /etc/supervisor/supervisord.conf.bak sudo cp /etc/supervisor/supervisord.conf /etc/supervisor/supervisord.conf.bak
sudo cp conf/example/supervisord.conf /etc/supervisor/supervisord.conf sudo cp conf/example/supervisord.conf /etc/supervisor/supervisord.conf
sudo chmod 777 /etc/supervisor/conf.d sudo chmod 777 /etc/supervisor/conf.d
@ -26,4 +29,4 @@ echo 'lihai_lot_walnutpi_dev_1' | tee device_name
sudo systemctl enable supervisor sudo systemctl enable supervisor
sudo systemctl start supervisor sudo systemctl start supervisor
sleep 60 sleep 60
supervisorctl reload supervisorctl reload

View File

@ -192,11 +192,11 @@ def get_data():
'wind_direction': winddirection_data, 'wind_direction': winddirection_data,
'create_time': int(time.time()) 'create_time': int(time.time())
} }
if sun_data < 2000: # if sun_data < 2000:
subprocess.Popen(['sudo python /home/pi/lot_manager/close_led.py'], shell=True) # subprocess.Popen(['sudo python /home/pi/lot_manager/close_led.py'], shell=True)
subprocess.Popen(['/bin/bash /home/pi/lot_manager/bash/stop_push_stream.sh'],shell=True) # subprocess.Popen(['/bin/bash /home/pi/lot_manager/bash/stop_push_stream.sh'],shell=True)
else: # else:
subprocess.Popen(['sudo python /home/pi/lot_manager/open_led.py'], shell=True) # subprocess.Popen(['sudo python /home/pi/lot_manager/open_led.py'], shell=True)
t2 = LOT_DATA(**data) t2 = LOT_DATA(**data)
client.publish(publish_topic, payload=json.dumps(data, ensure_ascii=False), qos=0) client.publish(publish_topic, payload=json.dumps(data, ensure_ascii=False), qos=0)
add(t2) add(t2)