I have a python script that I would like to run through cron every minute

* * * * * /usr/bin/python3 /home/analytics/Documents/devDeliverables/attendanceReadTsv/check_raw.py

when I run this using a non-root terminal, it runs alright. It raises an access denied error but that's still fine.

when I run this using a root terminal, it executes all the way through.

I'm checking /var/log/cron and it does not show any errors whatsoever. Also with /var/log/messages, I don't see any errors with the python call.

What the python script does is it converts tsv to xlsx, and it deletes the raw files. But it does not delete the file.

  • Where did you enter this crontab line? If it is somewhere in /etc/, a user name should be right after * * * * *, e.g.: * * * * * root /usr/bin/python3 /home/analytics/Documents/devDe...
    – Hkoof
    Sep 19, 2018 at 15:12

1 Answer 1


this sounds dumb but I'll answer anyway. the reason why it is not running as expected is because when I am running the script from the terminal, I am on the correct path where the script is.

now when cron runs, it changes the directory to /root. so my expected folder where it should run is not really where it is.

I added further logging on the cron so I can see the output from python.

* * * * * /usr/bin/python3 /home/analytics/Documents/devDeliverables/attendanceReadTsv/check_raw.py >> /home/analytics/Documents/devDeliverables/attendanceReadTsv/logs.txt 2>&1
  • So prepend the command with cd /the/correct/path &&
    – Kusalananda
    Aug 20, 2021 at 5:40
  • this sounds dumb - not at all. Getting stuff running under cron is rife with problems like this! Dec 21, 2022 at 16:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .