【发布时间】:2012-07-05 01:13:19
【问题描述】:
我有 debian linux。我从用户crontab -e 创建了这段文字:
0 * * * * python /home/user/CronLogic.py
15 * * * * python /home/user/CronLogic.py
30 * * * * python /home/user/CronLogic.py
45 * * * * python /home/user/CronLogic.py
*/1 * * * * date > /tmp/TEST
最后一个字符串运行良好,但运行 python 脚本失败:
/bin/sh: 1: /usr/bin/rcssserver: not found
代码是:
#!/usr/bin/python
cmd ='/usr/bin/rcssserver'
err = open('CronLogicERRORS', 'a')
server = subprocess.Popen(cmdRes, shell=True, stderr=err)
并且错误出现在CronLogicERRORS 文件中。这里有什么问题?没有 cron 脚本运行良好。
【问题讨论】:
-
Python 变量是
cmd但cmdRes传递给子进程。可能值得在子进程中避免使用 shell? -
好吧,从给定的例子来看,Python 并不是真正需要的。也许 OP 没有显示整个 Python 脚本。