I want to commit some file changes using a cron job calling a script with the following line in roots crontab
0 * * * * cd /files/ && ./backup.sh >/tmp/cronlog 2>/tmp/cronerror
the script looks as follows:
#!/usr/bin/env bash
… prepare the files for the backup …
echo "commit changes …"
git add -u
git commit -m "backup"
git push
Prior to the cron setup I've also set user.email
and user.name
for the root user and I've checked that the script runs if I call if from the command line.
But in /tmp/cronerror
I receive the following well known message.
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
…
I've also tried setting HOME=/root
in the script but this doesn't seam to make a difference.
Is there a way of telling the git command where to find the global git-config when running in a cron job?
我的解决方案是使用git config …
不带--global
选项,它将配置存储在当前存储库中,git可以在其中找到它。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.