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?