Git auto-pull using cronjob

后端 未结 5 1537
死守一世寂寞
死守一世寂寞 2020-12-12 12:55

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

5条回答
  •  离开以前
    2020-12-12 13:22

    */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.

提交回复
热议问题