Skip to content

Instantly share code, notes, and snippets.

@eugenpirogoff
Forked from jazlopez/crontab-git-update.sh
Last active November 15, 2019 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eugenpirogoff/1b811ecf57a0215073f1515b20d2f51c to your computer and use it in GitHub Desktop.
Save eugenpirogoff/1b811ecf57a0215073f1515b20d2f51c to your computer and use it in GitHub Desktop.
Git pull inside root crontab
# crontab (by executing sudo opens up root crontab)
sudo crontab -e
# every 1 minute pull changes (if any) and replace $user with real username
*/1 * * * * su -s /bin/sh $user -c 'cd /var/www/html/src && /usr/bin/git pull origin master && /usr/bin/git checkout master'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment