I'm currently working on a project that I'd like to commit to a repo on a daily basis as a tertiary backup. I've written the following little script to quickly commit my changes for the day:
REPO_PATH="/Users/niekvandepas/my-project"
git -C "$REPO_PATH" add -A
git -C "$REPO_PATH" commit -m "`date`"
The script works as expected, committing my changes for the day with a timestamp. Now I'd like to be able to automatically run this script on a daily basis. I tried using cron for this, but I'm running into an issue regarding (I think) directory or file permissions.
I've put the above script in /usr/local/bin/commitscript.sh and have verified that it still works. I then added the following line to my user crontab (crontab -e, no sudo):
0 10 * * * /usr/local/bin/commitscript.sh > /tmp/cron.log 2> /tmp/cron.err
However, when 10:00 comes around, my changes are not committed, and /tmp/cron.err has the following lines:
fatal: Unable to read current working directory: Operation not permitted
fatal: Unable to read current working directory: Operation not permitted
I'm assuming both of these are fatal git errors, for git add and git commit, respectively. This is confusing to me, since it's my user crontab, and the git repo resides in my home directory. Any ideas?
By the way, I'm running macOS Big Sur 11.4 and have granted iTerm full disk access.
