Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
date updated tags description
2021-04-04 17:19:08 +0200
2021-06-15 10:12:15 +0200
What Cron Jobs are, how to set them up, what are the ones I use

Cron Jobs essentially consist in running some command from the terminal at a predefined time, or every given interval.
They are great and useful since they can be used to automate any type of task.


Short answer

Run crontab -e

Long answers

Enable logging

Cron Jobs do not log activity by default, to activate logging for an easier debugging, go to /etc/rsyslog.conf or /etc/rsyslog.d/50-default.conf and uncomment the following line:

cron.*					/var/log/cron.log

then run

sudo service rsyslog restart && sudo service cron restart

Cron Jobs logs will be in /var/log/cron.log


My Cron Jobs


This Cron Job schedules [[Linuxplosion]] boot, and it switches it off until the following week.

35 18 * * 1 sudo udisksctl mount -b /dev/sda2 && echo "`date`: Linuxplosion is up and running!" >> ~/rtcwake-log.txt
0 21 * * 1 echo "`date`: Linuxplosion is going back to sleep until next monday at 7PM." >> ~/rtcwake-log.txt && sudo rtcwake -m off -t "$(date -d 'next Monday 18:30' '+%s')"


This Cron Job saves a list of predefined pages to The Wayback Machine using wayback_archiver

0 1 * * 1 /usr/local/bin/wayback_archiver --crawl --limit=100 --verbose --log=$HOME/wayback_archiver.log && echo "\n$(date) wayback_archiver success!" >> $HOME/wayback_archiver.log