Python脚本不在crontab上运行

时间:2017-11-07 14:00:11

标签: python cron

我想定期运行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

0 个答案:

没有答案