Git auto-pull using cronjob
Solution:
*/1 * * * * su -s /bin/sh nobody -c 'cd ~dstrt/www && /usr/local/bin/git pull -q origin master'
While you do need to figure out how to get the update to work in the first place, you'd be far better off using a hook from the upstream to make it go. You can do this simply with curl from a post-commit
hook or if you're using github, just use a post-receive hook on their side.
*/1 * * * * su -s /bin/sh nobody -c 'cd /home/heilee/src/project && /usr/bin/git pull origin master'
This corrects a couple errors that prevented the accepted answer from working on my system (Ubuntu >10.04 server). The key change seems to be the -q
after the pull
rather than before. You won't notice that your pull isn't working until you tail the /var/log/syslog
file or try to run your non-updated production code.