自动备份shell github
我写了一个脚本来自动备份一个网站,这个脚本将把资源推送到github。我在crontab中编写了一些代码,让它自动执行。然而,我不知道为什么不能推动资源 我可以从自动备份shell github,github,backup,cron-task,Github,Backup,Cron Task,我写了一个脚本来自动备份一个网站,这个脚本将把资源推送到github。我在crontab中编写了一些代码,让它自动执行。然而,我不知道为什么不能推动资源 我可以从.git中看到头部,它已被修改(这意味着提交成功)。我想问题在于用户名的使用不正确 以下信息是自动备份脚本的输出 Committer: root <root@xxxx.(none)> Your name and email address were configured automatically based on
.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'
您应该首先在自己的帐户下测试该脚本,其中必须正确设置git config user.name
和user.email
然后您应该注册脚本topcron
,确保它是
以不同的用户身份运行cron
作业:
su--c
委员会确认:
我通过在crontab中更改用户(而不是像以前那样root
)解决了我的问题
剧本(或大意)是什么?另外,您的计算机上是否有与root相关联的github公钥?我对cron不太熟悉,但我想一种方法可能是使用su
将其包装起来,以将您更改为正确的用户。谢谢。我通过在crontab中更改用户(而不是根用户)解决了我的问题。@YulongTian好的,为了更直观,我在答案中包含了你的结论。
`[remote "originTyl"]`
`url = https://accoutName:password@github.com/xxxx/xxxx.git`
`fetch = +refs/heads/*:refs/remotes/originTyl/*`
su - <user> -c <command or script>