Skip to content Skip to sidebar Skip to footer

Why Does A Python Script Work From The Cli, But Not When Called From A Cron Job?

I have created a Python script that I want to run daily via a cronjob on an Ubuntu server. This is how this script would be run from the Command Line: python /home/username/public

Solution 1:

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.

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

Post a Comment for "Why Does A Python Script Work From The Cli, But Not When Called From A Cron Job?"