CRON Schedule script operations |
Top Previous Next |
This script command provides FileLink with extensive scheduling capabilities which surpasses those of the PAUSE command.
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 FileLink 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 crontab file. You may use a file of any name, but if you do not specify a file name in the CRON command, FileLink uses a default name of "crontab.txt".
The format of this file is complex (see Crontab File Format) 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.
Technically savvy users may want to consider the following example where FileLink executes a unique script file on each weeknight at 11PM. The crontab file located in the FileLink working folder, named "crontab.txt", would contain:
# run a script at 11PM every weekday
0 23 * * mon CALL "Monday.s" 0 23 * * tue CALL "Tuesday.s" 0 23 * * wed CALL "Wednesday.s" 0 23 * * thu CALL "Thursday.s" 0 23 * * fri CALL "Friday.s"
The FileLink 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:
*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 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, WORKINGDIR See also: Crontab File Format, Using the %nextcmd Variable
|