Cron is a time-based scheduling service in Unix-like computer operating systems. 'cron' is short for 'chronograph'.
Generally, the schedules modified by crontab are enacted by a daemon, crond, which runs constantly in the background and checks once a minute to see if any of the scheduled jobs need to be executed. If so, it executes them. These jobs are generally referred to as cron jobs.
Each line of a crontab file represents a job and follows a particular format as a series of fields, separated by spaces and/or tabs. Each field can have a single value or a series of values.
There are several ways of specifying multiple date/time values in a field:
- 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"
- The asterisk ('*') operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to 'every hour' (subject to matching other specified fields).
There is also an operator which some extended versions of cron support, the slash ('/') operator (called "step"), 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".
So "*" specifies 'every hour' but the "*/3" means only those hours divisible by 3.
# +---------------- minute (0 - 59) # | +------------- hour (0 - 23) # | | +---------- day of month (0 - 30) # | | | +------- month (1 - 12) # | | | | +---- day of week (0 - 6) (Sunday=0 or 7) # | | | | | * * * * * command to be executed
Commands to be executed can be any shell commands, like calling programs or running shell scripts (see OS/OS Documentation for more details).
Here's an example of a CronTab file on the QNAP:
# m h dom m dow cmd 0 4 * * * /sbin/hwclock -s 0 3 * * * /usr/local/sbin/ImR_all -soft /Qmultimedia
=> The first job runs the shell command "/sbin/hwclock -s" every day at 04:00 hrs.
Note that several Crontab are stored in different locations on the QNAP. The "master CronTab" is located in /mnt/HDA_ROOT/.config/crontab. In order to make permanent changes, you need to edit this file
Some Linux directories are mapped into RAM (see MountPoints). Thus they will be erased on the next reboot.
Location of all Crontab files on the QNAP:
|Root Directory||Device||Link / Comment||Master|
|/etc/default_config||RAM||contains fewer datasets, not updated|
|/mnt/HDA_ROOT/rootfs_2_3_6/tmp/cron/crontab.1237||HDD||sometimes not there|
|/tmp/cron/crontab.1237||RAM||sometimes not there|
|/var/lib/pcmcia/cron/crontab.1237||RAM||sometimes not there|
|/var/pcmcia/cron/crontab.1237||RAM||sometimes not there|
|/var/run/cron/crontab.1237||RAM||sometimes not there|
|/var/spool/cron/crontab.1237||RAM||sometimes not there|
|/var/tmp/cron/crontab.1237||RAM||sometimes not there|
To display the current CronTab file (show the settings), logon to your QNAP using PuTTY and enter the command
=> See How To/Change CronTab for details.