3 cron

cron is the name of the program that is responsible to run “jobs” periodically on most unix-based systems. In Debian systems, cron is automatically started when the system starts up normally.

To add a task to cron, you need to use the command “crontab -e”. crontab can be used by any user on a normal system. This means that a normal user can also set up jobs to be run periodically. This command starts an editor (the default is nano, but you can change that to any editor). You have to edit a text file to specify what command to run when.

Each line in the editor has the following fields, in the following order:

For more details, please consult the man pages of cron and and crontab. Particularly, for the format of the file, use man 5 crontab.

As the man page says, you can also use special words starting with the “at” symbol (@) to specify commonly used options. Of these options, the most important one is @reboot, which specifies the command should be run once at system start up. This one is special because there is no other way to specify a command to run at start up, especially for a regular end user.

When you use cron it is a good idea to space out commands that are resource intensive. For example, the job to back up a file system probably should not run when with a virus scanning job. This is because these two jobs will compete for input/output resources, resulting in both jobs being run slowly. In this case, the two jobs probably can be combined if the administrator has some scripting experiences. This automatically means that @daily should be used sparingly!

Note that cron cannot be used to schedule any jobs that run more frequently than every minute.