```bash #! /bin/bash date=$(date +"%Y-%m-%d %T") #command substitution links date commans to date variable in format Y-M-D-T message="Commit for $date" # commit message cd ~/Documents/'Obsidian Vault' #moves to loc that has been initialized as a local git repo git add . #adds all files in local repo to index git commit -m "${message}" status="$(git status --branch --porcelain)" #checks to see if changes made today echo $status >> ~/cron_echo.txt if [ "$status" == "## main...origin/main" ]; then echo "IT IS CLEAN" >> ~/cron_echo.txt else echo "There is stuff to push" >> ~/cron_echo.txt git push -u origin main fi ``` - Make script exec and add to directories within `$PATH` ```bash chmod +x script.sh #make script executable $PATH #show path directories sudo cp git-push.sh /usr/bin/git-push.sh && sudo cp git-push.sh /usr/local/bin/git-push.sh #copy script into directories that our system expects to contain executable scripts and code ``` - Add `crontab` entry to run script according to deterministic schedule ```bash sudo service cron status #check cron ervice status crontab -e #opens crontab in nano editor 0 2 * * * bash ~/loc/git-push.sh #runs script every day at 0200 ```