我想定期运行python
脚本,因此我使用crontab
。这就是我crontab -e
的样子:
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/opt/python/libexec/bin
*/1 * * * * PYTHONPATH=/usr/local/lib/python/2.7/site-packages /usr/local/opt/python/libexec/bin/python /Users/username/Desktop/processes/test.py
我正在使用的python
版本是从home-brew
下载的。
正如我在很多情况下看到的那样,我可以手动运行test.py
,但crontab -e
似乎不起作用。我可能已经包含了额外的东西,但我不认为这些会影响输出。
我通过cat /var/mail/username
得到的错误就是这个错误:
Traceback (most recent call last):
File "/Users/username/Desktop/processes/test.py”, line 34, in <module>
subprocess.call(['bash', commands_txt_shortened]) # Run the txt file to retrieve the images.
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 168, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 390, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1025, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory