【问题标题】:How do I schedule a python script using cron on OS X Catalina如何在 OS X Catalina 上使用 cron 调度 python 脚本
【发布时间】:2020-02-26 05:49:47
【问题描述】:

所以我正在尝试在 Mac OS X Catalina 10.15.3 中设置一个 cron 作业。出于某种原因,我可以让我的 python 脚本运行。我在它下面设置了一个测试作业,它运行良好。

* * * * * python3 /Users/eric/Dropbox/python/Print/New\ Orders/funcs.py
* * * * * echo 'hello' >> //Users/eric/Desktop/test/test.txt
``

the echo is running every minute but for some reason I cant the the python file to run.

【问题讨论】:

  • 尝试使用python3的完整路径?

标签: python-3.x cron macos-catalina


【解决方案1】:

最安全的选择是将完整路径放入脚本。对于您的具体情况,您可以通过执行which python3 找到它。
或者,您可以将 PATH 定义添加到您的 crontab 中,例如,

PATH=$PATH:/usr/local/bin:/Users/abc/path/to/python

此外,您可以将 stdout 和 stderr 重定向到某个文件,以便更清楚地了解正在发生的事情

* * * * * python3 /Users/eric/Dropbox/python/Print/New\ Orders/funcs.py 1>/tmp/stdout.log 2>/tmp/stderr.log

【讨论】:

    猜你喜欢
    • 2018-01-26
    • 2015-07-12
    • 1970-01-01
    • 2012-04-24
    • 1970-01-01
    • 2018-03-20
    • 1970-01-01
    • 2018-03-25
    • 1970-01-01
    相关资源
    最近更新 更多