Scheduling Script Execution
|Top Previous Next|
One of the most useful features of Robo-FTP is the ability run a script that transfers files unattended at scheduled times. There are three basic approaches to achieve this result.
Option 1: Launching a Robo-FTP Script using the Scheduler.
Option 2: Launching Robo-FTP as a Windows Service
Instead of scheduling a script, you may wish to run Robo-FTP as a Windows service so it will be automatically launched whenever the system reboots. Installing Robo-FTP as a Windows service is easy using a service script designed to run in an infinite loop and either the Service Installer or Enterprise Dashboard utilities.
Option 3: The Scheduling Script Commands.
The PAUSE command is easy to use and is best suited for simple schedules. This command suspends script execution either for a fixed period of time (e.g., 60 minutes) or until a fixed time of day (e.g., 11PM). At the designated time, the script “wakes up” and continues execution. When this command is used in a service script, it is typically at the top of an infinite loop such that execution waits for the appropriate time then continues to log in, transfer files, and log off before ultimately looping back to the PAUSE command at the top of the loop where it waits for the next designated time to run.
The CRON command may be used to create complex schedules. This command, like the PAUSE command, suspends script execution for a period of time and is typically used at the top of a loop. However, unlike PAUSE, the duration of the CRON command's suspension is determined by a schedule stored in an external file. You can use CRON to schedule processes “every Tuesday and Thursday at 11PM”, “once a month at midnight of the 5th day”, “every 15 minutes on March 30”, and so on. Robo-FTP includes the CronMaker scheduling utility to help you build the "crontab.txt" file that the CRON command uses for these types of schedules.
Using the CRON Command - A Brief Overview
When scheduling task(s) with CRON, there are usually three discrete components that need to be created:
Let's suppose you create a script file named "Monday.s" that transfers files to headquarters. First, you test this script works as a stand-alone script BEFORE using it in a CRON-based scheduling loop. Next you'll use the CronMaker utility to create an event schedule file named “crontab.txt” that will be used with the CRON command. You add an event named MondayHQ that sets CALL "Monday.s" as the value of the %nextcmd variable and runs weekly on Monday at 2:00 AM. Now you make a simple master CRON loop scrip that looks something like this:
CRON is the first command in the loop so Robo-FTP evaluates your schedule file and determines the duration of the suspension. In this example, MondayHQ is the only event in the schedule so execution is suspended until next Monday morning. When the program awakens from the suspension, CALL "Monday.s" is the value stored in the %nextcmd variable so the PERFORM command in the master loop script causes your Monday.s script to run. After the Monday.s script completes its work, control returns to the master loop script where the GOTO command restarts the loop.
Once everything is working properly, use the Service Installer or the Enterprise Dashboard to create a Windows service that runs the master CRON loop script. Later, when you have additional automation needs, you can use the CronMaker utility to insert new events into your crontab.txt schedule. The new events may specify different event scripts to CALL with the PERFORM command and the %nextcmd variable.
File and folder permissions must be considered when selecting the credentials under which a service or Scheduled Task will run. The LOCAL SYSTEM and NETWORK SERVICE built-in accounts are common choices but you may also choose a normal user account or a user account designated as a service account. Whichever account you choose must have access to any local or network resources required by your command script.