I want to run a script daily with Crontab, then, I added that line:

30 1 * * * /usr/bin/python3 /home/pi/.../uploadFiles.py >/dev/null 2>&1

If I copy and past the line /usr/bin/python3 /home/pi/.../uploadFiles.py in terminal, it works perfectly. But with Crontab, nothing happens.

And I can see the log with grep CRON /var/log/syslog:

Feb  3 01:30:01 raspberrypi CRON[4460]: (pi) CMD (/usr/bin/python3 /home/pi/.../uploadFiles.py >/dev/null 2>&1)

I have the Python shebang at the begin of my script : #!/usr/bin/python3. And the chmod of my script is good I think:

-rwxr-xr-x  1 pi   pi     3949 Feb  3 14:00  uploadFiles.py

The purpose of this script is to send files to my Google Drive with the Google's API (and also an email for warning). I got no emails and the files are not uploaded (with Cron).

If you have any advice, thanks in advance.

2 Answers 2


I found the problem.

Actually I was referring to some folders (the one where the files to upload are) with relative paths. It works when I run the script directly with python command, but not with Cron. So I updated all the paths with absolute values, and now it works :)

  • Congratulations! Please mark your answer as the accepted one when you can (I think there's a waiting time before you can do this). ICYI, there are many Q&A here on cron, so have a glance before you dash off a question.
    – Seamus
    Feb 3, 2021 at 22:57

As you have to with cron if you had put a PATH= in your script it would have found the files. Cron does not inherit any PATH or other environment variables they need to be set or you use absolute paths to the files, as you discovered.

  • I am not used that yet, so I am discovering step by step :) I will check for the PATH, that could avoid me absolute one everywhere Feb 8, 2021 at 7:09

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