Skip to content

Instantly share code, notes, and snippets.

@jazlopez
Created October 25, 2016 00:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jazlopez/3106944230c539ae83d9905d8f76534b to your computer and use it in GitHub Desktop.
Save jazlopez/3106944230c539ae83d9905d8f76534b to your computer and use it in GitHub Desktop.
Git pull inside root crontab
# Git repository may not allow root to pull down updates
# Pull updates where $user is allowed to read/write remote.
# command line:
su -s /bin/sh $user -c 'cd /var/www/html/src && /usr/bin/git pull origin master'
# crontab (by executing sudo opens up root crontab)
sudo crontab -e
# every 1 minute pull changes (if any)
*/1 * * * * su -s /bin/sh $user -c 'cd /var/www/html/src && /usr/bin/git pull origin master'
@jazlopez
Copy link
Author

@myalcin81 thank you for sharing your version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment