Git auto-pull using cronjob

kayue picture kayue · Dec 11, 2010 · Viewed 79.6k times · Source

I was trying to create a cronjob with a task to do a git pull every minute to keep my production site in sync with my master branch.

The git pull needs to be done by the system user nobody, due to the permissions problem. However it seems that the nobody account is not allowed run commands. So I have to create tasks as the root user.

The crontab entry I tried:

*/1 * * * * su -s /bin/sh nobody -c 'cd ~heilee/www && git pull -q origin master' >> ~/git.log

It doesn't work, and I don't know how to debug it.

Could anyone help?

UPDATE1: the git pull command itself is correct. I can run it without errors.

Answer

kayue picture kayue · Dec 11, 2010

Solution:

*/1 * * * * su -s /bin/sh nobody -c 'cd ~dstrt/www && /usr/local/bin/git pull -q origin master'