1

ウェブサイトを自動バックアップするスクリプトを作成しました。このスクリプトはリソースを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

このシェル スクリプトの主要部分は次のとおりです。


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/*`
4

1 に答える 1

0

まず、自分のアカウントでそのスクリプトをテストする必要があります。ここで、git config user.nameuser.emailを適切に設定する必要があります。

次に、スクリプトを登録する必要があります top cronユーザーが独自の.rootcrontab

cron別のユーザーとしてジョブを実行します。

su - <user> -c <command or script>

OP Yulong Tianはコメントで次のように確認しています。

rootcrontabでユーザーを(以前とは異なり)変更することで問題を解決しました。

于 2013-05-13T07:18:32.043 に答える