Python脚本不通过Cron工作? [英] Python Script Not Working Via Cron?
问题描述
我有一个python脚本运行另一个python脚本。
I have a python script that runs another python script. that 'other script' (script being run) takes ~ 45[min] to complete.
当'执行'脚本从Ubuntu的shell运行时,它一切正常。
When the 'execution' script is run from Ubuntu's shell, it all works perfectly.
我向cron添加了一个条目来运行'execution'python脚本。它似乎一开始运行,但程序在几秒钟后终止:
I added an entry to cron to run the 'execution' python script. It seems to run at first, but the program is terminated after a few seconds:
user@internet:~/REMOTE_CONTROL$ ps aux | grep python
user 1603 0.0 1.4 31504 15184 ? S 22:50 0:00 python /usr/share/system-config-printer/applet.py
root 1714 0.0 0.7 13672 8012 ? S 22:51 0:00 /usr/bin/python /usr/lib/system-service/system-service-d
**user 7956 109 1.0 14380 10692 ? R 23:48 0:01 python /media/READ_ONLY/DEVELOPER/COMPOSITE/CURRENT/DataLoader.py**
user 8029 0.0 0.0 3320 788 pts/1 S+ 23:48 0:00 grep --color=auto python
user@internet:~/REMOTE_CONTROL$ ps aux | grep python
user 1603 0.0 1.4 31504 15184 ? S 22:50 0:00 python /usr/share/system-config-printer/applet.py
root 1714 0.0 0.7 13672 8012 ? S 22:51 0:00 /usr/bin/python /usr/lib/system-service/system-service-d
**user 7956 100 1.1 15448 11900 ? R 23:48 0:07 python /media/READ_ONLY/DEVELOPER/COMPOSITE/CURRENT/DataLoader.py**
user 8033 0.0 0.0 3320 788 pts/1 S+ 23:48 0:00 grep --color=auto python
user@internet:~/REMOTE_CONTROL$ ps aux | grep python
user 1603 0.0 1.4 31504 15184 ? S 22:50 0:00 python /usr/share/system-config-printer/applet.py
root 1714 0.0 0.7 13672 8012 ? S 22:51 0:00 /usr/bin/python /usr/lib/system-service/system-service-d
**user 7956 97.2 1.2 15992 12412 ? R 23:48 0:11 python /media/READ_ONLY/DEVELOPER/COMPOSITE/CURRENT/DataLoader.py**
user 8035 0.0 0.0 3320 792 pts/1 S+ 23:48 0:00 grep --color=auto python
user@internet:~/REMOTE_CONTROL$ ps aux | grep python
user 1603 0.0 1.4 31504 15184 ? S 22:50 0:00 python /usr/share/system-config-printer/applet.py
root 1714 0.0 0.7 13672 8012 ? S 22:51 0:00 /usr/bin/python /usr/lib/system-service/system-service-d
user 8037 0.0 0.0 3320 792 pts/1 S+ 23:48 0:00 grep --color=auto python
我可能会失踪什么?我尝试替换正在由执行脚本触发的脚本,并让它调用一个简单的脚本,只是执行以下操作:
any idea what I might be missing? I tried to replace the script that is being triggered by the 'execution' script, and have it call a simple script that just does the following:
while(1):
....print "hi"
$ b b
仍然无法运作。
and it still does not work.
任何想法?感谢。
(我使用的是Ubuntu 10.04 LTS)
(I am using Ubuntu 10.04 LTS)
推荐答案
在尝试从cron运行时,通常会有一些常见的误解。
There are usually a few common misunderstandings made when trying to run things from cron.
- 没有会话。
- PATH和其他环境变量在用户会话和cron执行环境之间几乎总是不同的。
当cron失败时,它会默认尝试发送邮件。您可以查看您的本地邮箱或队列(如果您的mta已关闭)错误。
When cron fails it will by default attempt to send mail. You can look in your local mail box or queue (if your mta is down) for errors.
这篇关于Python脚本不通过Cron工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!