[英]Running python script from crontab
I've got a python file called color.py
that if I run using python color.py
will work on a file.我有一个名为
color.py
的 python 文件,如果我使用python color.py
运行,它将处理一个文件。 I can run it okay from the terminal but it doesn't get called from crontab.我可以从终端运行它,但它不会从 crontab 调用。 I've used
chmod +x color.py
to try and make it executable.我已经使用
chmod +x color.py
尝试使其可执行。
The py file does start with py 文件确实以
#!/usr/bin/env python
and the cron command is而 cron 命令是
*/1 * * * * /root/images/color.py
First check if following command works by running as user root (su or sudo):首先通过以 root 用户(su 或 sudo)运行来检查以下命令是否有效:
/usr/bin/python /root/images/color.py
If that works, then edit crontab to:如果可行,则将 crontab 编辑为:
*/1 * * * * /usr/bin/python /root/images/color.py
How do you check if the cron job succeeds or not?您如何检查 cron 作业是否成功?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.