我想知道我的crontab作业是否正确编写。我希望在VPS上运行它们,并且实际上不可能对其进行监视。事不宜迟,这里是我的cron工作:
# cd into directory at 2:57 AM
57 2 * * 1-5 cd /folder_name
# activate the virtual environment
58 2 * * 1-5 . env/bin/activate
# run the main script
59 2 * * 1-5 python main.py
# at 5pm break the script (worried the most about this part)
0 16 * * 1-5 ^C
另外,我将系统时钟更改为东部时间,这是否意味着cron作业将使用东部时区运行?
不,cron
不是外壳。编写脚本:
#!/bin/sh
cd /folder_name
. env/bin/activate
exec python main.py
使它可执行,然后指向crontab
它的一个条目:
57 2 * * 1-5 /path/to/script
然后,脚本应该在本地时区(您的计算机认为是)的每个星期一至星期五的2:57运行。如果正确配置了邮件系统,则将结果(如果有)邮寄给您。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句