如何在 OS X Catalina 上使用 cron 安排 python 脚本
How do I schedule a python script using cron on OS X Catalina
所以我正在尝试在 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.
最安全的选择是放置脚本的完整路径。对于您的具体情况,您可以通过执行 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
所以我正在尝试在 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.
最安全的选择是放置脚本的完整路径。对于您的具体情况,您可以通过执行 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