CRON        Schedule script operations

<< Click to Display Table of Contents >>

Navigation:  Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands >

CRON        Schedule script operations

Syntax

CRON

[ file name ]

Alt Syntax:

CRON

[ @ cond ]  [ cmd ]

Arguments:

[ file name ]

Variable or string defining a file or path name; if no path is defined the default path is searched for a matching file; this cron event file contains one or more scheduling conditions; if omitted, the default file is "crontab.txt" in Robo-FTP's working folder; see Cron Event File Format.

 

[ @ cond ]

Variable or string specifying one of Robo-FTP's pre-defined scheduling conditions; these conditions must begin with the '@' symbol (e.g., @hourly).

 

[ cmd ]

Optional variable or string to be stored in the %nextcmd variable; this permits a particular command to be performed when a pre-defined scheduling condition is matched; see Using the %nextcmd Variable.

Options:

none

 

 

 

The CRON command may be used to create complex schedules. The CRON command, like the PAUSE command, suspends script execution for a period of time. However, unlike PAUSE, the duration of the CRON command's suspension is determined by either (1) an event condition string or by (2) an external schedule file. You can use a schedule file to define complex schedules like “every Tuesday and Thursday at 11PM”, “once a month at midnight of the 5th day”, “every 15 minutes on March 30”, etc. Robo-FTP includes the CronMaker scheduling utility to help you build these types of schedule files. For an overview of Robo-FTP scheduling, see Scheduling File Transfers With Robo-FTP.

 

Single event scheduling is achieved using one of the following scheduling condition strings:

 

@yearly

midnight Jan 1

@monthly

midnight on the first day of each month

@weekly

midnight each Sunday

@daily

midnight each day

@hourly

every hour at the top of the hour

@every2hours

midnight, 2am, 4am, 6am, 8am, 10am, etc.

@every4hours

midnight, 4am, 8am, noon, 4pm and 8pm

@every6hours

midnight, 6am, noon and 6pm

@every8hours

midnight, 8am and 4pm

@twicedaily

midnight and noon

@onhalfhour

30 minutes after the top of the hour

@everyhalfhour

top of the hour and 30 minutes after the hour

@every15min

top of the hour and 15, 30, 45 minutes after

@every5min

top of the hour, 5, 10, 15, 20, 25, etc. minutes after

 

Consider the following example where Robo-FTP sends a file every 30 minutes.

 

:loop

;; note the use of both single and double quotation marks

CRON "@onhalfhour" 'SENDFILE "30minutes.dat"'

PERFORM %nextcmd

GOTO loop

 

More complex scheduling conditions may be achieved using a schedule contained in a CRON event file. This file is named "crontab.txt" by default but you may change the name if necessary. The format of this file is complex (see Cron Event File Format) so you should probably use the CronMaker utility provided with Robo-FTP to create and modify schedule files.

 

If you are planning to run Robo-FTP as a service, consider the following example where Robo-FTP runs in a continuous loop and executes a unique script file each weeknight at 11PM. The crontab.txt event file would contain:

 

# run a script at 11PM every weekday

0 23 * * monCALL "Monday.s"
0 23 * * tueCALL "Tuesday.s"
0 23 * * wedCALL "Wednesday.s"
0 23 * * thuCALL "Thursday.s"
0 23 * * friCALL "Friday.s"

 

The looping Robo-FTP script file would look like:

 

:loop

CRON

PERFORM %nextcmd

GOTO loop

 

When the CRON command executes it will display a confirmation message to the console as to when the next CRON event will trigger. Using the previous example, if today is Monday at 5PM, the CRON command would confirm the next event to occur at 11PM later that day with the following message:

 

*CALL "Monday.s" will trigger at Wed May 30 23:00:00 2012

 

When no command string is specified, the CRON command is similar to the PAUSE command in that it simply waits until there is a match in schedule time(s) before script execution is allowed to resume.

 

Important

If there are multiple trigger events in the crontab.txt file, be aware that CRON does not queue events that may occur at the same time. For example, if you have two events that are scheduled to trigger at 3:30PM, CRON will act only upon the first and the second will be ignored. If you need to have multiple scripts run at the same time off of a single event trigger, you should make a single corresponding script “smart” enough to use the CALL script command to run the other(s) sequentially.

 

Note: The [ cmd ] argument may be used with either method of determining the duration of the suspension but, if used with a schedule file, the argument is used to set %nextcmd instead of the equivalent value stored in the file.

 

 

Related command(s): PAUSE, PERFORM, CALL, PRESANYKEY

See also: CronMaker Utility, Cron Event File Format, Using the %nextcmd Variable, Scheduling Script Operations, Programming Service Scripts, Default Path