[Django]-Why does a Python script work from the CLI, but not when called from a cron job?

5👍

The crontab probably cannot find the python executable although it can on the CLI, so you need to write down the complete path to python. The same you get from

which python

Crontab supplies an environment for the scripts, which is not the same as the normal user environment.

👤Navi

2👍

3 17 * * * /bin/sh python /home/username/public_html/IDM_app/manage.py cleanUpPosts  

this line seems wrong. It seems you’re running python as if it was a shell script.

👤nosklo

Leave a comment