crontab (cron table)

Schedule a command to run at a later time

      crontab [ -u user ] file
      crontab [ -u user ] { -l | -r | -e }

   -l  List - display the current crontab entries.

   -r  Remove the current crontab.

   -e  Edit the current crontab using the editor specified by the 
       VISUAL or EDITOR environment variables.
       After you exit from the editor, the modified crontab will be installed automatically.

Crontab is the program used to install, deinstall or list the tables used to drive the cron daemon in Vixie Cron.
Each user can have their own crontab, and though these are files in /var, they are not intended to be edited directly.

If the -u option is given, it specifies the name of the user whose crontab is to be tweaked. If this option is not given, crontab examines "your" crontab, i.e., the crontab of the person executing the command. Note that su can confuse crontab and that if you are running inside of su you should always use the -u option for safety's sake.

cron file is used to install a new crontab from some named file or standard input if the pseudo-filename `-' is given.

Each line in the cron table follows the following format:

* * * * *  Command_to_execute
- – – – -
| | | | |
| | | | +—– Day of week (0–6) (Sunday=0) or Sun, Mon, Tue,…
| | | +———- Month (1–12) or Jan, Feb,…
| | +————-— Day of month (1–31)
| +——————– Hour (0–23)
+————————- Minute (0–59)

There are several ways of specifying multiple values in a field:

• The asterisk (*) operator specifies all possible values for a field. e.g. every hour or every day.
• The comma (,) operator specifies a list of values, for example: "1,3,4,7,8"
• The dash (-) operator specifies a range of values, for example: "1-6", which is equivalent to "1,2,3,4,5,6"

There is also an operator which some extended versions of cron support, the slash (/) operator, which can be used to skip a given number of values. For example, "*/3" in the hour time field is equivalent to "0,3,6,9,12,15,18,21"; "*" specifies 'every hour' but the "/3" means that only the first, fourth, seventh...and such values given by "*" are used.

Cron will email to the user all output of the commands it runs, to silence this, redirect the output to a log file or to /dev/null


Run /usr/bin/ at 12.59 every day and supress the output (redirect to null)
59 12 * * * simon /usr/bin/ > /dev/null 2>&1

# Run everyday at 9pm (21:00)
0 21 * * * 1>/dev/null 2>&1

# Run every Tuesday to Saturday at 1am (01:00)
0 1 * * 2-7 1>/dev/null 2>&1

# Run at 07:30, 09:30 13:30 and 15:30
30 07,09,13,15 * * *

If the allow file exists, then you must be listed therein in order to be allowed to use this command. If the allow file does not exist but the deny file does exist, then you must not be listed in the deny file in order to use this command. If neither of these files exists, then depending on site-dependent configuration parameters, only the super user will be allowed to use this command, or all users will be able to use this command.

"Wisdom is the power to put our time and our knowledge to the proper use" ~ Thomas J. Watson


cron - daemon to execute scheduled commands
nice - Change job scheduling priority
builtin - Run a shell builtin
chroot - Run a command with a different root directory
exec - Execute a command
nohup - Run a command immune to hangups
.source - Run commands from a file
su - Run a command with substitute user and group id
watch - Execute/display a program periodically
Equivalent Windows command: schtasks - Schedule a command to run at a later time

© Copyright 1999-2016
Some rights reserved