【发布时间】:2020-08-31 17:58:04
【问题描述】:
我正处于 ubuntu 服务器的学习阶段。我有一个 Python 脚本,每天早上都会给我发送天气信息,当我从命令行运行它时,该脚本可以完美运行。但是,当我尝试设置 crontab 条目时,它不起作用。以下行是我放入 crontab 文件的内容:
30 11 * * * cd /home/ubuntu/documents && /usr/bin/python /home/ubuntu/documents/weatherText.py
我还尝试了以下方法:
30 11 * * * /usr/bin/python /home/ubuntu/documents/weatherText.py
当我在终端中输入以下任一命令时,我的 python 脚本运行良好。
1.) cd /home/ubuntu/documents && /usr/bin/python /home/ubuntu/documents/weatherText.py
2.) /usr/bin/python /home/ubuntu/documents/weatherText.py
这一定是cron的问题,对吧?如果您现在正在查看此内容,感谢您抽出宝贵时间。
【问题讨论】:
-
你检查 cron 的日志文件了吗?
-
@MattSchuchard 我已将它们添加到我的帖子中!
标签: python ubuntu cron crontab