One of the most useful utilities in FreeBSD is cron. This utility runs in the background and regularly checks
/etc/crontabfor tasks to execute and searches
/var/cron/tabsfor custom crontab files. These files are used to schedule tasks which cron runs at the specified times. Each entry in a crontab defines a task to run and is known as a cron job.
Two different types of configuration files are used: the system crontab, which should not be modified, and user crontabs, which can be created and edited as needed. The format used by these files is documented in crontab(5). The format of the system crontab,
whocolumn which does not exist in user crontabs. In the system crontab, cron runs the command as the user specified in this column. In a user crontab, all commands run as the user who created the crontab.
User crontabs allow individual users to schedule their own tasks. The
rootuser can also have a user
crontabwhich can be used to schedule tasks that do not exist in the system
Here is a sample entry from the system crontab,
# /etc/crontab - root's crontab for FreeBSD # # $FreeBSD: head/en_US.ISO8859-1/books/handbook/config/chapter.xml 45038 2014-06-09 03:58:34Z wblock $ # SHELL=/bin/sh PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin # #minute hour mday month wday who command # */5 * * * * root /usr/libexec/atrun
Lines that begin with the
The equals (
This line defines the seven fields used in a system crontab:
This entry defines the values for this cron job. The
Commands can include any number of switches. However, commands which extend to multiple lines need to be broken with the backslash “\” continuation character.