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/
DIRNAME="$( dirname -- "$( readlink -f -- "$0"; )"; )"

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

date >> /tmp/cronlog
echo $DIRNAME >> /tmp/cronlog

# # in crontab -e
# # * * * * * /bin/bash $HOME/me/me-qs/backup.sh > /tmp/cronlog
# # odd hours:
# # * 1-23/2 * * *  /bin/bash $HOME/me/me-qs/backup.sh > /tmp/cronlog
# # every 10 minutes:
# 1-59/10 * * * *  /bin/bash $HOME/me/me-qs/backup.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