This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!
cron is a daemon that runs scheduled tasks based on input from the command
accomplishes this task by waking up every minute and checking to see if there are any cron jobs to
run in any of the user
Table of contents¶
There are multiple cron implementations, in this cheat sheet I will use
cronie (fork of
vixie-cron, because according to the Gentoo Wiki:
vixie-cron is a bit outdated while still maintained by Fedora).
First, check if
cronie is already installed:
Warning to NixOS users
There is no
cronie nix package, only
cron (which is
vixie-cron), so for the rest
of this cheat sheet: remember to replace any
cronie reference by
cron. But be
warned that the following sections may not correctly apply to
If not, install it ...
Then, add it to your init system and start it:
Depending on your
runit implementation, either run:
cronie doesn't need to be configured anymore.
# vi /etc/crontab > # Global variables > SHELL=/bin/bash > PATH=/sbin:/bin:/usr/sbin:/usr/bin > MAILTO=root > HOME=/ > > # check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly > 59 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly > 9 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily > 19 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly > 29 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly > */10 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons
crontabsare located in
Add a line to the wanted
crontabaccording to this format:
E.g. execute a command every ...
Check the file syntax of your
By default one can check cron executions by reading the logs in
/var/log/messagesand searching for
anacron is not a cron daemon, it is something that usually works in conjunction with one. It
executes commands at intervals specified in days and it does not assume that the system is running
continuously; it will run jobs that were missed while the system was down.
anacron usually relies
on a cron daemon to run it each day.
anacron functionalities (note to Gentoo users:
anacron functionalities when the default
anacron use flag is set).
If this cheat sheet has been useful to you, then please consider leaving a star here.