Scheduling File Transfers With Robo-FTP |
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 two basic approaches to achieve this result, either: (1) use the Windows Task Scheduler to launch Robo-FTP with a script that transfers a file and then exits or (2) create a Windows service that is always "running" but only transfers files at the times you specify.
Option 1: Launching Robo-FTP from the Windows Task Scheduler The Windows Task Scheduler may be used to automate the execution of Robo-FTP command scripts if you create a task that uses the appropriate command line switches to launch Robo-FTP.exe and execute your script. The -s switch must be used to specify the name of the script file. The -v switch is also recommended because it allows the task to run silently in the background. The -r switch should be used if it would be a problem for multiple instances of Robo-FTP to concurrently execute the same script file. Scripts started as scheduled tasks should close Robo-FTP with the EXIT command to avoid leaving the process running in memory.
In Windows 2003 and XP you can create a Task by opening the Scheduled Tasks folder in the Control Panel. In Windows 2008 Server the Task Scheduler is listed under Administrative Tools. If you are using Windows 7 the Task Scheduler may be found under either Control Panel -> System and Security -> Administrative Tools or under All Programs -> Accessories -> System Tools depending on which version of Windows 7 you have.
If you are using the Windows Task Scheduler we strongly recommend adding Robo-FTP to the Path environment variable. You won't need to specify the full path to Robo-FTP.exe after adding the Robo-FTP installation directory to your system's Path environment variable. After editing the path in Windows 2003 and XP you can do this:
... if you use the Basic Task Wizard in Windows 7 or Windows 2008 Server it will look like this:
Note: If you use the Basic Task Wizard and you need the task to be executed under the security context of a particular user or service account other than the current user, then you'll need to modify the properties of your newly created task.
Option 2: Launching Robo-FTP as a Windows Service Instead of launching a Scheduled Task, 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.
The Scheduling Script Commands Regardless of how you launch Robo-FTP, scheduling operations within a command script may be accomplished by using the PAUSE or CRON 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.
Permissions 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.
Related command(s): EXIT, PAUSE, CRON, PERFORM, CALL, GOTO, RETURN See also: Scheduling Script Operations, Installing Robo-FTP as a Windows Service, Working with Network Drives, Simultaneous Execution |