Crontab

Crontab (short for cron-table) is a Linux scheduler . It consists of a daemon called cron (after the Greek god of time, Kronos), which reads the cron-table every minute and executes the commands at the right time.

This service is used to configure and manage the cron-table that lists the scheduled tasks that run at regular time intervals on the system.

Configuration

To configure the Crontab (cron-table); select the Crontab service and click the "Main config. file..." button. See screenshot.

Each entry in the cron-table file has five time- and date-fields, followed by a username and command.

Any of the fields can be set to an asterisk (*), which stands for "first through last". For instance, to run a job every hour, put * in the Hour field.

Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive; for example, 4-7 for an "hours" entry specifies execution at hours 4, 5, 6 and 7.

Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: "1,2,5,9", "0-4,8-12".

Step values can be used in conjunction with ranges. For example, "0-23/2" in the Hours field means "every other hour." Steps are also permitted after an asterisk, so if you want to say "every two hours", you can use "*/2".

Names can also be used for the "month" and "day of week" fields. Use the first three letters of the particular day or month (case doesn't matter). Ranges or lists of names are not allowed.

The "sixth" field contains the user-name, that the command will be run under. Using "root" will give the highest privileges.

The "seventh" field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile. Percent signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.

Note that the day of a command's execution can be specified by two fields: day of month, and day of week. If both fields are restricted (in other words, they aren't *), the command will be run when either field matches the current time. For example, "30 4 1,15 * 5" would cause a command to be run at 4:30 AM. on the 1st and 15th of each month, plus every Friday.

Note: Daylight savings can effect the job schedules, where jobs can be run twice or skipped.

Each line of the cron-table file is either "active" or "inactive". An "active" line is an environment setting, or a command entry. An "inactive" line is anything ignored, including comments.

Blank lines and leading spaces and tabs are ignored. Lines whose first non-space character is a # sign are interpreted as comments, and are ignored. Comments are not allowed on the same line as commands, because they are interpreted as part of the command. For the same reason, comments are not allowed on the same line as environment variable settings.

Example of services that use crontab:

DINGO backup: 15 6 * * * root /opt/GoIoT/DinGo/bin/general/rn_dingo_backup_and_upload.sh (daily, at 6:15 AM.)

Logrotate dingo.log: 35 * * * * root logrotate /etc/logrotate.d/dingo-stack (hourly, at 35 minutes past the hour.)

Modem check: */1 * * * * root /opt/GoIoT/DinGo/bin/modem/rn_check_ppp0.sh (every minute.)

OpenPort check: 10 * * * * root /opt/GoIoT/DinGo/bin/network/rn_check_openport.sh (hourly, at 10 minutes past the hour.)

Note: The cron-table file is check every minute, so any changes made to the configuration file, will take effect immediately.