I am trying to get a cronjob to run a basic Python script as a proof-of-concept exercise. The Python script goes as follows:
#!/usr/bin/python
with open('realfile','a+') as f:
f.write('testwrite\n')
My script is located (along with the 'realfile' file) in a 'Documents' directory that is one below my home directory (i.e. $HOME/Documents).
My crontab is as follows:
*/1 * * * * /$HOME/Documents/crontest.py
For some reason the crontab does not execute the script every minute as it should. The script works fine, as I manually ran it from command line (using ./crontest.py). In addition, the crontab worked completely fine when the script was located in the home directory and the crontab was simply:
*/1 * * * * /$HOME/crontest.py
I have checked the location of 'crontest.py' using 'locate crontest.py' and I got the following two locations:
/home/meric/crontest.py
/usr/bin/crontest.py
I tried setting both of these paths in my crontab, and still the job won't run.
What could be the problem? Thanks for the help!