Automate Reboot and Git push with Linux Crontab

1200px-Tux.svg

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.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s