serhii.net

In the middle of the desert you can say anything you want

21 Jun 2024

Arch cron

sudo pacman -S cronie
sudo systemctl enable cronie.service

# many minutes were lost due to me forgetting to start it as well...
sudo systemctl start cronie.service

Cron git backup script

#!/bin/bash

# https://stackoverflow.com/posts/1482133/
# get the directory where this file is located
DIRNAME="$( dirname -- "$( readlink -f -- "$0"; )"; )"

cd $DIRNAME &&
git add -A &&
git commit -m "Automatic backup at `date`" &&
git push origin master &&
echo "Done"

# and this is the crontab
# odd hours:
# * 1-23/2 * * *  /bin/bash $HOME/this-script-location.sh > /tmp/cronlog

EDIT: sometimes if git crashes an index file stays and then nothing runs — so the cronjob must be somehow monitored manually, todo.

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus