How do I schedule a python script using cron on OS X Catalina

雨燕双飞 提交于 2020-08-11 03:14:28

问题


So i'm trying to setup a cron job in Mac OS X Catalina 10.15.3. For some reason I can get my python script running. I setup a test job under it and that one works perfectly.

* * * * * 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.

回答1:


The safest option is the put the full path to the script. For your specific case you can find it by executing which python3.
In alternative, you can add the PATH definition into your crontab, e.g.,

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

Also, you could redirect the stdout and stderr to some file to have a clearer view of what's going on

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


来源:https://stackoverflow.com/questions/60407554/how-do-i-schedule-a-python-script-using-cron-on-os-x-catalina

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!