首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自动备份外壳github

自动备份外壳github
EN

Stack Overflow用户
提问于 2013-05-13 03:12:40
回答 1查看 639关注 0票数 1

我编写了一个自动备份网站的脚本,这个脚本将把资源推送到github。我用crontab编写了一些代码,让它自动执行。然而,我不知道为什么资源不能被推下去。

我可以从.git中看到它已经被修改(这意味着提交成功)。我想问题是用户名的使用不正确。

以下信息是自动备份脚本的输出。

代码语言:javascript
复制
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中的命令:

代码语言:javascript
复制
*/2 * * * * root /var/backWiki.sh >/home/xxx/Tmp/4.txt

下面是这个shell脚本的主要部分:

代码语言:javascript
复制
git pull originTyl master
git add -A
echo '2'
git commit -a -m $nowtime
echo '1'
git push originTyl master
echo '3'

origninTyl的意思是:

代码语言:javascript
复制
`[remote "originTyl"]`
`url = https://accoutName:password@github.com/xxxx/xxxx.git`
`fetch = +refs/heads/*:refs/remotes/originTyl/*`
EN

回答 1

Stack Overflow用户

发布于 2013-05-13 07:18:32

您应该首先在您自己的帐户下测试该脚本,其中必须正确设置git config user.nameuser.email

然后,您应该注册您的脚本顶级cron,确保它是rootcrontab

以不同用户的身份运行cron作业:

代码语言:javascript
复制
su - <user> -c <command or script>

OP Yulong Tian确认in the comments

我通过更改crontab中的用户(而不是以前的root )来解决我的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16514357

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档