cron

Table of Contents

cron is a periodical job scheduling program present in almost all linux distros, and definitely in debians.

To use cron, edit etc/crontab:

1. link

see anacron

Backlinks

Here is a script using cron, anacron and rsync to backup my important files

0 *	* * *	linfeng	anacron -t ${HOME}/etc/anacrontab -S ${HOME}/var/spool/anacron

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin


1 0 /usr/bin/rsync -aAX --delete --exclude '*.Trash-1000' /home/linfeng/Dropbox/Notes/ /media/linfeng/backup/Notes/daily
7 10 /usr/bin/rsync -aAX --delete --exclude '*.Trash-1000' /home/linfeng/Dropbox/Notes/ /media/linfeng/backup/Notes/weekly
@monthly 15  /usr/bin/rsync -aAX --delete --exclude '*.Trash-1000' /home/linfeng/Dropbox/Notes/ /media/linfeng/backup/Notes/monthly_$(date +%Y%m%d)

anacron

anacron is a program to schedule periodic task. Anacron assume your computer to not be running 24*7, and use timestamp to record last executed time of jobs. unlike cron, anacron will execute missed jobs.

Author: Linfeng He

Created: 2024-04-03 Wed 20:20