Python cronjob无法运行 [英] Python cronjob won't run
问题描述
当我通过SSH进入我的Ubuntu 6.4 VM并运行 python nomi.py
时,我的脚本将按预期执行。
When I am SSH'd into my Ubuntu 6.4 VM and run python nomi.py
, my script executes as it should.
我如下设置我的crontab文件,以便每15分钟运行一次脚本:
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
我设置crontab文件的方式有什么问题吗?创建crontab文件后,我需要做任何事情吗?
Is there anything wrong with how I set up the crontab file? Do I need to do anything after the crontab file is created?
nomi.py
文件将数据发送到Google分析,当我运行脚本时,数据就会通过。当我尝试让cron作业运行脚本时,什么也没发生。
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表
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
推荐答案
以下问题建议您使用绝对路径,而不要依赖〜
扩展到主目录。
The following question suggests that you should use absolute paths instead of relying on ~
to expand to your home directory.
还要确保 cron
实际上正在运行。您可以通过grepping cron
进程来做到这一点。在Ubuntu Linux上,我通常使用以下命令。
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
这篇关于Python cronjob无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!