CRON Schedule script operations |
Top Previous Next |
This script command provides Robo-FTP with extensive scheduling capabilities which surpasses those of the PAUSE command.
For an overview of Robo-FTP scheduling, see Scheduling File Transfers With Robo-FTP.
Two forms of scheduling are supported: (1) predefined conditions for a single event (e.g., twice daily); and (2) complex user defined conditions (e.g., 4PM Monday through Friday and midnight Sunday).
In either case, a script command (or other character string) may be specified to be saved in the %nextcmd variable when there is a match. Often this will be a command to execute a particular script file at the time of the event. (The command would be executed in a subsequent PERFORM command.) This command string is optional.
Single event scheduling is achieved using one of the following designators:
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 are achieved using the CRON command slightly differently and uses a file containing one or more conditions. This file is referred as a cron event file. You may use a file of any name, but if you do not specify a file name in the CRON command, Robo-FTP uses a default name of "crontab.txt".
The format of this file is complex (see Cron Event File Format) 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.
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, located in the Robo-FTP working folder, would contain:
# run a script at 11PM every weekday
The looping Robo-FTP script file would look like:
:loop CRON 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:
*CRON will trigger at 11:00PM today and run this command: "CALL "Monday.s""
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.
Related Command(s): PAUSE, PERFORM, WORKINGDIR, CALL See also: CronMaker Utility, Cron Event File Format, Using the %nextcmd Variable, Scheduling Script Operations, Programming Service Scripts
|