我编写了一个自动备份网站的脚本,这个脚本将把资源推送到github。我用crontab编写了一些代码,让它自动执行。然而,我不知道为什么资源不能被推下去。
我可以从.git中看到它已经被修改(这意味着提交成功)。我想问题是用户名的使用不正确。
以下信息是自动备份脚本的输出。
Committer: root <root@xxxx.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 14 insertions(+), 14 deletions(-)我该怎么处理呢?
crontab中的命令:
*/2 * * * * root /var/backWiki.sh >/home/xxx/Tmp/4.txt下面是这个shell脚本的主要部分:
git pull originTyl master
git add -A
echo '2'
git commit -a -m $nowtime
echo '1'
git push originTyl master
echo '3'
origninTyl的意思是:
`[remote "originTyl"]`
`url = https://accoutName:password@github.com/xxxx/xxxx.git`
`fetch = +refs/heads/*:refs/remotes/originTyl/*`发布于 2013-05-13 07:18:32
您应该首先在您自己的帐户下测试该脚本,其中必须正确设置git config user.name和user.email。
然后,您应该注册您的脚本顶级cron,确保它是root,crontab。
以不同用户的身份运行
cron作业:
su - <user> -c <command or script>OP Yulong Tian确认in the comments
我通过更改crontab中的用户(而不是以前的
root)来解决我的问题。
https://stackoverflow.com/questions/16514357
复制相似问题