I have a python file that has to be run with sudo
elevation every 6 hours.
I created the cronjob using sudo crontab -e
and then added the entry:
0 */6 * * * cd /home/timeflow/backup && sudo /usr/bin/python3 /home/timeflow/backup/backup_db.py
However, this file is never ran. I have also tried removing sudo
from sudo /usr/bin/python3 home/timeflow/backup/backup_db.py
, however this does nothing as well. For clarity:
0 */6 * * * cd /home/timeflow/backup && /usr/bin/python3 /home/timeflow/backup/backup_db.py
I have no idea why this is not working. I tried to do a smaller job, by creating a random python file in the same repo to no avail. The entry was:
* */6 * * * touch /home/timeflow/test.py
/var/log/syslog
show any entries related to these cronjobs? Also try the answers in https://askubuntu.com/q/23009/158442 – muru Jun 01 '22 at 07:49/var/log/syslog
seems to show that the cronjobs are running properly. – chxnge Jun 01 '22 at 08:03cd
andpython3
commands. Modify the python program to print debugging messages to sysout. Have cron run that script instead, and redirect sysout and syserr to a log file. – Jos Jun 01 '22 at 09:03