I am trying to automate a Python script on a Google Cloud VM using Crontab.
When I run python Daily_visits.py my code runs as expected and generates a table in BigQuery.
My Crontab job is as follows: */2 * * * * /usr/bin/python Daily_visits.py but generates no output.
I've run which python and I get /usr/bin/python back, and I have run chmod +x Daily_visits.sh on my file, what else am I missing?
You should write absolute path for Daily_visits.py file. Go to Daily_visits.py file's directory and run command:
pwd
You take output like it:
/var/www/Daily_visits.py
Copy and paste it change into crontab.
*/2 * * * * /usr/bin/python /var/www/Daily_visits.py
Automating a Python script with Crontab