[Top] | [Contents] | [Index] | [ ? ] |
This document is intended to layout the specification for the GNU Cron project.
1. Explanation 2. Goals 3. Specification
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An explanation of why GNU Cron (or gcron for short ) was started is important in understanding the direction the project wishes to head. At the present time the most common cron daemon in use and available is Vixie cron (by Paul Vixie) and although it would seem that this package has fit the needs of a cron daemon so far, we do not see things the same.
Firstly, Vixie cron is very outdated. Vixie Cron v3.0 was released in December of 1993; basically, there is no longer any central active maintainer of the package. Several problems arise from this:
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter covers the actual specification GNU Cron will follow during it's development. It is separated into three sections: Compatibility with Vixie Cron, Compliance with POSIX, and Extra Features.
3.1 Vixie Cron What needs to be done to maintain backward compatibility 3.3 POSIX What needs to be done to comply with POSIX 3.4 Extras Which extra features are being proposed 3.5 at Description of the 'at' command
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.1.1 File Format The format of a file parsed by cron 3.1.2 Matching How cron matches moments in time 3.2 crontab Specification of the crontab command
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Blank lines, and lines beginning with a pound character ('#') are ignored by cron.
The basic file format consists of lines with 6 fields separated by any number of whitespace characters (excluding newlines). The first five fields describe the times in which each job is to be executed.
The fourth field, Month of the Year, may also be three letter abbreviations of the months. The abbreviations must only be the first three letters of the month. (XXX: Can we do ranges like this? Jan-Mar?)
The fifth field, Day of the Week, also can be three letter abbreviations. The abbreviations may only be the first three letters of the days of the week. (XXX: Can we do ranges like this? Mon-Fri?) Also of note is that 0 and 7 are both considered Sunday.
The sixth field is the command that is too be executed should cron determine a match with the 5 previous fields (see section 3.1.2 Matching). The sixth field is no longer space delimited so that no special consideration need be taken by the user to pass arguments to the command successfully.
Each of the first five fields may be an asterisk (denoted a match for all possible values), an element, or a list of elements delimited by commas. An element may be a single number, a range of numbers, or a ranger of numbers followed by a '/' and a step value. A range of numbers is denoted by a number followed by a hyphen followed be another number and are inclusive values. Step values tell cron to skip certain numbers in the range given. A step value may also be applied to an asterisk, in which case an asterisk is treated as a range value encompassing the full range of values allowed in that field.
Examples:
1,3-6,10 -- matches the values 1,3,4,5,6,10
1-20/4 -- matches the values 1,5,9,13,17 (XXX: I'm not sure if this is right or not, it might be 4,8,12,16,20?)
2-10/2,5 -- matches 2,4,5,6,8,10 (XXX: again, might not be right--is step like a modulus operator?)
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In addition to this variable and value pairs may be specified (XXX anywhere?) in the file which are set as environment variables, as well as exported to each job's environment. A couple of variables affect the way cron will handle jobs as outlined below.
Variables are denoted in a crontab file by a line starting with a variable identifier followed by an equal sign and finally by the variable's value. Such as: PATH=.:/bin:/usr/bin
Any number of blanks on either side of the equals sign are allowed and discarded by cron. For example: PATH = .:/bin:/usr/bin sets the "PATH" variable to ".:/bin:/usr/bin". (XXX: This (and above) needs to look nicer in output, what's the best way to do it?) Anything after the first non-blank character in a value is literal.
If beginning blanks are needed for the value of a variable the value may be enclosed in either single or double quotes so much as they match. Anything enclosed in the quotes becomes literal to the value of the variable. To put double quotes in the value of a variable, enclose the entire value in single quotes and vice versa.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The system file /etc/crontab deviates slightly from the standard format of a cron file. It's location on the system will be a compile time option but for most systems will be /etc/crontab.
This file has an extra field between the fifth and sixth fields of a standard cron file. So, in /etc/crontab, the 'job field' becomes the seventh field. The new sixth field is the name of some user on the system and tells cron to run that job as the specified user.
It is also useful to note that this file is not installed via the crontab command (XXX reference here) but is read by cron on startup and whenever a change is detected.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
(minute && hour && month && (DoM || DoW))
This is somewhat counter-intuitive to the obvious ANDing of all five fields. The follow examples will help clarify.
(XXX insert examples)
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[Top] | [Contents] | [Index] | [ ? ] |
1. Explanation
2. Goals
3. Specification
3.1 Vixie Cron
3.1.1 File Format3.2 crontab
Environment Variables
/etc/crontab
3.1.2 Matching
3.3 POSIX
3.4 Extras
3.5 at
[Top] | [Contents] | [Index] | [ ? ] |
1. Explanation
2. Goals
3. Specification
[Top] | [Contents] | [Index] | [ ? ] |
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ < ] | Back | previous section in reading order | 1.2.2 |
[ > ] | Forward | next section in reading order | 1.2.4 |
[ << ] | FastBack | previous or up-and-previous section | 1.1 |
[ Up ] | Up | up section | 1.2 |
[ >> ] | FastForward | next or up-and-next section | 1.3 |
[Top] | Top | cover (top) of document | |
[Contents] | Contents | table of contents | |
[Index] | Index | concept index | |
[ ? ] | About | this page |