使用cronjob Git自动拉 [英] Git auto-pull using cronjob
问题描述
我试图创建一个cronjob任务,每分钟做一个 git pull
,以保持我的生产网站与我的主分支同步。
由于权限问题,git pull需要由系统用户 nobody
完成。但是,似乎不允许运行 nobody
帐户。所以我必须创建任务作为 root
用户。
我尝试的crontab条目:
* / 1 * * * * su -s / bin / sh nobody -c'cd〜heilee / www& git pull -q origin master'>> 〜/ git.log
它不工作,我不知道如何调试。
有人能帮助吗?
UPDATE1: git pull
命令本身是正确的。
<$ p $ p>
* / 1 * * * * su -s / bin / sh nobody -c'cd〜dstrt / www&& / usr / local / bin / git -q pull origin master'
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.
Solution:
*/1 * * * * su -s /bin/sh nobody -c 'cd ~dstrt/www && /usr/local/bin/git -q pull origin master'
这篇关于使用cronjob Git自动拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!