Cron Event File Format |
Top Previous Next |
Borrowed from Unix, a cron event file (named crontab in the Unix world) contains instructions to the FileLink CRON script command of the general form: "run this command at this time on this date".
The format of this file is complex and not something the casual user needs to be concerned with. The CronMaker Utility is provided with FileLink for the direct creation and modification of “crontab.txt” files. The curious may read on for the “techie” details.
Each line of the file has five time and date fields, followed by an optional command to be saved in the %nextcmd variable. Blank lines, leading spaces, and tabs are ignored. Lines whose first non-space character is a pound-sign (#) are comments and are ignored. Note that comments are not allowed on the same line as CRON commands, since they will be taken to be part of the command.
Commands are executed by CRON when the minute, hour, and month fields match the current time, and when at least one of the two day fields (day of month or day of week) match the current day. The time and date fields are:
A field may be an asterisk (*), which always stands for "don't care".
Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 8-11 for an hour entry specifies execution at hours 8, 9, 10 and 11.
Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: 1,2,5,9 and 0-4,8-12.
Step values can be used in conjunction with ranges. Following a range with /<number> specifies skips of the number's value through the range. For example, 0-23/2 can be used in the hour field to specify command execution every other hour. Steps are also permitted after an asterisk, so if you want to say every two hours, just use */2.
Names can also be used for the month and day of week fields. Use at least the first three letters of the particular day or month (case doesn't matter) (e.g., Mon, Jan, etc.) Ranges or lists of names are allowed (e.g., Mon-Wed).
The rest of the line following the day of week field, if present, specifies the command to be saved in the %nextcmd script file variable.
Note 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 (i.e., aren't *), a match occurs when either field matches the current day. For example, 30 4 1,15 * 5 would cause a match at 4:30AM on the 1st and 15th of each month, plus every Friday.
Consider the following examples.
# run a script 5 minutes after midnight, every day
# send a file at 2:15pm on the first of every month
# resume script processing at 10PM on weekdays 0 22 * * 1-5
# resume at 23 minutes after midnight, 2AM, 4AM ..., everyday
# run a script at 5 minutes after 4AM every Sunday
Multiple events may be specified in the “crontab.txt” file to trigger at the different times as shown below:
# run a script at 5PM and 11PM everyday
Beware that it is possible for different events in the “crontab.txt” file to trigger at the same time as shown below:
# run a script at 5PM everyday
# run a script every hour on Sunday
In this example, both events are scheduled to trigger at 5PM on Sunday. You probably want to avoid this situation since only the first match event (i.e., running the script “Daily.s”) will be acted upon. In this example, the “AllDaySunday.s” script will never be run at 5PM on Sunday.
Refer to the Using the FileLink CronMaker Utility, Using The %nextcmd Variable and CRON for more details.
|