Reputation: 1132
In my project i have to schedule a job on my subuntu server; i try using Cron like this:
$ sudo nano /etc/crontab
and then , at the end of the file, append my command:
00 5 * * * ubuntu /usr/bin/python /var/www/web/core/frontend/allschemas.py
for start my python file call every day at 5 pm. If i try to manual launche from server command, al was done, but my cron job never start, and never log error or warning.
Someone has idea about this issue?
So many thanks in advance
Upvotes: 0
Views: 249
Reputation: 7225
Your record in cron should look like:
0 5 * * * /usr/bin/python /var/www/web/core/frontend/allschemas.py
If you want to start the job at 5 a clock in the morning, if its 5 a clock after noon record become
0 17 * * * /usr/bin/python /var/www/web/core/frontend/allschemas.py
Also be aware that if python depend of some environment variables the job will fail. Better create shell script which will execute the job and add before execution line like this:
. /home/username/.bash_profile
Upvotes: 0
Reputation: 793
Cron will run after re-editing your commands.
00 5 * * * ubuntu cd /var/www/web/core/frontend && /usr/bin/python allschemas.py
You can also use per user cront:located in
/var/spool/cron/crontabs/<username>
Example:
echo "00 5 * * * cd /var/www/web/core/frontend && /usr/bin/python allschemas.py" >> /var/spool/cron/crontabs/root #or /var/spool/cron/crontabs/<username>
Upvotes: 1