Skip to content

Instantly share code, notes, and snippets.

@tuguchev-andrey
Forked from jazlopez/crontab-git-update.sh
Created January 29, 2022 14:54
Show Gist options
  • Select an option

  • Save tuguchev-andrey/8b344e578ff7c233db38034205a40d73 to your computer and use it in GitHub Desktop.

Select an option

Save tuguchev-andrey/8b344e578ff7c233db38034205a40d73 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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment