我想使用 cron 作业提交一些文件更改,调用一个脚本,并在 root crontab 中使用以下行
0 * * * * cd /files/ && ./backup.sh >/tmp/cronlog 2>/tmp/cronerror
该脚本如下所示:
#!/usr/bin/env bash
… prepare the files for the backup …
echo "commit changes …"
git add -u
git commit -m "backup"
git push
在 cron 设置之前我还设置了user.email
and user.name
对于 root 用户,我检查了如果从命令行调用 if 则脚本是否运行。
But in /tmp/cronerror
我收到以下众所周知的消息。
*** Please tell me who you are.
Run
git config --global user.email "[email protected] /cdn-cgi/l/email-protection"
git config --global user.name "Your Name"
to set your account's default identity.
…
我也尝试过设置HOME=/root
在脚本中但这似乎没有什么区别。
有没有办法告诉 git 命令在 cron 作业中运行时在哪里找到全局 git-config ?
我的解决方案是使用git config …
没有--global
选项将配置存储在当前存储库中,git 可以在其中找到它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)