Git 使用 cronjob 自动拉取 [英] Git auto-pull using cronjob

查看:38
本文介绍了Git 使用 cronjob 自动拉取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个 cronjob,其任务是每分钟执行一次 git pull 以保持我的生产站点与我的主分支同步.

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.

由于权限问题,git pull需要系统用户nobody来完成.但是,似乎不允许 nobody 帐户运行命令.所以我必须以 root 用户身份创建任务.

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.

我尝试的 crontab 条目:

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.

有人可以帮忙吗?

UPDATE1:git pull 命令本身是正确的.我可以毫无错误地运行它.

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

推荐答案

解决方案:

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

这篇关于Git 使用 cronjob 自动拉取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆