Introduction
I am going to explain how you can set up daily git pushes with crontab command.
Step 1 – Disable git username/password prompt during check-in
Follow the steps on this StackOverflow post.
Step 2 – Add git commands to a sh file
Add following sh file to the repository root directory.
#!/usr/bin/expect #Pull remote repository git pull #Git commit and push git add -A #Commit git commit -a -m "Daily Update" git push
Step 3 – Open Crontab
sudo crontab -e
Step 4 – Setup Daily Executions
Add following line to the crontab file. This will run the script every 8am in the morning.
0 8 * * * PATH_TO_YOUR_SH_FILE
For example, the command I used was this.
0 8 * * * /home/myhome/project/gitpush.sh
Step 5 – Setup Daily Reboot
Refer to this askUbuntu post to set this up.