As Nic5300 suggested, an easy way to do this is to write a simple script that is called by cron
at a specific time:
auto_commit.sh
=======================================
#!/bin/bash
MESSAGE="Auto-commit: $(date)"
REPO_PATH="/home/user/repo"
git -C "$REPO_PATH" add -A
git -C "$REPO_PATH" commit -m "$MESSAGE"
Just update the REPO_PATH and MESSAGE with whatever you'd like. Now, you add the script to your crontab by running crontab -e
.
To run it every night at midnight, your crontab would look like this:
* 0 * * * auto_commit.sh > /dev/null 2>&1
Obviously, you'd have to update that path to wherever your script is saved. Just make sure you have cron
running (depends on what init system you're using), and you should be good to go. Check out https://crontab-generator.org if you want to fiddle more with your crontab.