Crontab not executing a Python script?

前端 未结 15 1534
囚心锁ツ
囚心锁ツ 2020-11-29 20:42

My python script is not running under my crontab.

I have placed this in the python script at the top:

#!/usr/bin/python

I hav

15条回答
  •  渐次进展
    2020-11-29 21:09

    It's usually because the python used by crontab is different from the one you use in the shell. The easiest way to solve this is:

    1. get the python you use in the shell:

    $ which python # it may be "python3" or something else /usr/bin/python

    1. use that specific python in crontab file:

    * * * * * /usr/bin/python test.py

    Also want to mention that using env -i /bin/bash --noprofile --norc in the shell lets you have the same environment as the one used by crontab, and this is super helpful to debug.

提交回复
热议问题