0

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.

0

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.