Python cronjob won't run

烈酒焚心 提交于 2019-12-25 05:55:27

问题


When I am SSH'd into my Ubuntu 6.4 VM and run python nomi.py, my script executes as it should.

I set up my crontab file as follows in order to run the script every 15 mins:

# m h  dom mon dow   command

*/15 * * * * /usr/bin/python home/cron1admin/nomi.py

Is there anything wrong with how I set up the crontab file? Do I need to do anything after the crontab file is created?

The nomi.py file sends data to Google Analytics, and when I run the script, the data goes through. When I attempt to let the cron job run the script, nothing happens.


ps aux | grep cron table

root      1029  0.0  0.0  19120   932 ?        Ss   Jun26   0:01 cron
root      5896  0.0  0.3  73448  3724 ?        Ss   16:41   0:00 sshd: cron1admin [priv]
1000      6084  0.0  0.1  73448  1656 ?        S    16:42   0:00 sshd: cron1admin@pts/0
root      6745  0.0  0.3  73448  3628 ?        Ss   18:07   0:00 sshd: cron1admin [priv]
1000      6926  0.0  0.1  73448  1552 ?        S    18:07   0:00 sshd: cron1admin@pts/1
1000      7065  0.0  0.0   9392   944 pts/1    S+   18:21   0:00 grep --color=auto cron

回答1:


The following question suggests that you should use absolute paths instead of relying on ~ to expand to your home directory.

Also make sure cron is actually running. You can do this by grepping for the cron process. On Ubuntu Linux, I usually use the following command.

ps aux | grep cron


来源:https://stackoverflow.com/questions/24520041/python-cronjob-wont-run

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!