Cron job doesn't run script python in the specific directory
I created a simple python script to add
, commit
, and push
all files in some directory. I want to do this daily by a scheduled cron job. But unfortunately, the script doesn't run. Before this, I do some research on how to check activities in my Ubuntu, and I see my cron job has been executed. So I was confused why the script doesn't run.
This is my cron job:
16 16 * * * cd ~/Desktop/Journey\ to\ Go/ && python auto-push.py
This is my python script:
import os
os.system('git add .')
os.system('git commit -m "auto push"')
os.system('git push')
The reason is the ~
as cron does not expand it to the path of your home directory like an interactive shell does. Please use full paths.