Cron Event File Format

Top  Previous  Next

 

Borrowed from Unix, a cron event file (named crontab in the Unix world) contains instructions to the Robo-FTP 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 Robo-FTP for the direct creation and modification of cron event 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: 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:

 

Field

Definition

Minute

Minutes after hour (0 - 59)

Hour

Hours since midnight (0 - 23)

Day of month

Day of month (1 - 31)

Month

Month (1 - 12; January = 1); or use name

Day of week

Day of week (0 - 6; Sunday = 0); or use name

 

A field may be an asterisk , which always stands for "All".

 

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.

 

 

Important

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

5 0 * * *call "daily.s"

 

# send a file at 2:15pm on the first of every month

15 14 1 * *sendfile "data.txt"

     

# resume script processing at 10PM on weekdays

0 22 * * 1-5

 

# resume at 23 minutes after midnight, 2AM, 4AM ..., everyday

23 0-23/2 * * *

 

# run a script at 5 minutes after 4AM every Sunday
5 4 * * suncall "Sunday.s"

 

# run a script every 2 hours every Sunday
0 */2 * * 0call "Sunday.s"

 

Multiple events may be specified in the cron event file to trigger at the different times as shown below:

 

# run a script at 5PM and 11PM everyday

0 17 * * *call "Daily5PM.s"
0 23 * * *call "Daily11PM.s"

 

Beware that it is possible for different events in the cron event file to trigger at the same time as shown below:

 

# run a script at 5PM everyday

0 17 * * *call "Daily.s"

# run a script every hour on Sunday

0 * * * suncall "AllDaySunday.s"

 

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 run at 5PM on Sunday.

 

Refer to the Using the Robo-FTP CronMaker Utility, Using the %nextcmd Variable and CRON for more details.