diff --git a/conf/example/cron_for_32G.conf b/conf/example/cron_for_32G.conf index 595e72b..c93208e 100644 --- a/conf/example/cron_for_32G.conf +++ b/conf/example/cron_for_32G.conf @@ -1,5 +1,9 @@ # 每天0:0分执行 0 0 * * * /usr/bin/python /home/pi/lot_manager/delete_lot_data_3_days.py +# 每天08:00分执行 +0 8 * * * sudo /usr/bin/python /home/pi/lot_manager/open_led.py +# 每天18:00分执行 +0 18 * * * sudo /usr/bin/python /home/pi/lot_manager/close_led.py # 针对32G内存卡的定时,额外加这个 # 每隔15分钟进行 -*/15 * * * * /usr/bin/python /home/pi/lot_manager/delete_than20G.py \ No newline at end of file +*/15 * * * * /usr/bin/python /home/pi/lot_manager/delete_than20G.py diff --git a/conf/example/cron_for_64G.conf b/conf/example/cron_for_64G.conf index b853aa3..5a52a83 100644 --- a/conf/example/cron_for_64G.conf +++ b/conf/example/cron_for_64G.conf @@ -2,4 +2,8 @@ # 每小时0分执行,32G的不用加 0 * * * * /usr/bin/bash /home/pi/lot_manager/bash/cron_delete_mp4.sh # 每天0:0分执行 -0 0 * * * /usr/bin/python /home/pi/lot_manager/delete_lot_data_3_days.py \ No newline at end of file +0 0 * * * /usr/bin/python /home/pi/lot_manager/delete_lot_data_3_days.py +# 每天08:00分执行 +0 8 * * * sudo /usr/bin/python /home/pi/lot_manager/open_led.py +# 每天18:00分执行 +0 18 * * * sudo /usr/bin/python /home/pi/lot_manager/close_led.py \ No newline at end of file diff --git a/cron_set.sh b/cron_set.sh new file mode 100644 index 0000000..f3fa11b --- /dev/null +++ b/cron_set.sh @@ -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 \ No newline at end of file diff --git a/install.sh b/install.sh index c3a4b45..3d3bd1e 100644 --- a/install.sh +++ b/install.sh @@ -10,11 +10,14 @@ git config --global user.name xyj git config --global user.email 1090822794@qq.com 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 git clone https://gitea.lihaink.cn/xyj/lot_manager.git cd lot_manager 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 conf/example/supervisord.conf /etc/supervisor/supervisord.conf 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 start supervisor sleep 60 -supervisorctl reload \ No newline at end of file +supervisorctl reload diff --git a/sensor_to_server.py b/sensor_to_server.py index 8d7df60..36fb812 100755 --- a/sensor_to_server.py +++ b/sensor_to_server.py @@ -192,11 +192,11 @@ def get_data(): 'wind_direction': winddirection_data, 'create_time': int(time.time()) } - if sun_data < 2000: - 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) - else: - subprocess.Popen(['sudo python /home/pi/lot_manager/open_led.py'], shell=True) + # if sun_data < 2000: + # 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) + # else: + # subprocess.Popen(['sudo python /home/pi/lot_manager/open_led.py'], shell=True) t2 = LOT_DATA(**data) client.publish(publish_topic, payload=json.dumps(data, ensure_ascii=False), qos=0) add(t2)