Python脚本不通过Cron工作?

use*_*424 2 python linux ubuntu cron

我有一个运行另一个python脚本的python脚本."其他脚本"(正在运行的脚本)需要大约45 [min]才能完成.

当'执行'脚本从Ubuntu的shell运行时,它完全正常.

我在cron中添加了一个条目来运行'execution'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  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
Run Code Online (Sandbox Code Playgroud)

知道我可能会缺少什么吗?我试图替换"执行"脚本触发的脚本,并让它调用一个简单的脚本,它只执行以下操作:

while(1):

....print "hi"
Run Code Online (Sandbox Code Playgroud)

它仍然无法正常工作.

有任何想法吗?谢谢.

(我使用的是Ubuntu 10.04 LTS)

die*_*dha 8

在尝试从cron运行时,通常会产生一些常见的误解.

  • 没有会话.如果您有需要会话的代码,则必须进行其他设置.
  • PATH和其他环境变量在用户会话和cron执行环境之间几乎总是不同的.

当cron失败时,它将默认尝试发送邮件.您可以查看本地邮箱或队列(如果您的mta已关闭)以查找错误.

  • 我建议在系统上使用"man"命令.男人crontab; 男人5 crontab; 男人的 男人8 cron.这些命令应该可以帮助您了解cron正在做什么以及对您开放的配置选项.MTA代表邮件传输代理.Google是您了解MTA的朋友. (2认同)