Call now to talk to an automation expert — (512) 345-2211

Script Library

Sample scripts are provided as-is with no warranty of fitness for a particular purpose. These scripts are solely intended to demonstrate techniques for accomplishing common tasks. Additional script logic and error-handling may need to be added to achieve the desired results in your specific environment.


queue_cron.s

Download

NOTE: As of version 3.10, Robo-FTP includes a new scheduler that is able to schedule jobs that launch at the same time and/or overlap. Access this scheduler via the Scheduler tab in the Configurator.

Robo-FTP's CRON command enables you to schedule jobs with a great deal of flexibility.

The basic process is simple:

  1. Create a crontab.txt file. Each line of the file contains a set of scheduling conditions like "every hour" or "every weekday at 5pm." Each line of the file also includes a string that gets stored in the %nextcmd variable automatically when that particular time condition is met.

  2. Create a script whose job it is to run in a perpetual loop that calls the CRON command (which tells Robo-FTP to check the crontab.txt file for the next scheduling condition to match) and does something when the next scheduling condition matches (usually used to call the PERFORM command to execute whatever command was stored in the %nextcmd variable).

Please consult the Help file for more details and examples of the technique described above.

One potential pitfall of using PERFORM %nextcmd in your looping CRON script is that PERFORM must wait for the scheduled script to finish before your script can loop back to the top and wait for the next scheduling condition to match.

If, for example, you have a script scheduled to run at 9:01am and another script scheduled to run at 9:02am, and the script that runs at 9:01am takes longer than one minute to complete, then the script that is scheduled to run at 9:02am will be skipped.

Update: CRON events are no longer skipped beginning with version 3.8

This is easily avoided in most cases by taking care not to schedule long-running scripts too closely, but this is not always possible. Additionally, this is the kind of problem that can crop up long after you initially set up the schedule (i.e., a script that used to only take 30 seconds now takes several minutes and therefore is causing another scheduled script to be skipped).

One technique for avoiding this situation reliably is to use EXEC with the /nowait option to launch a new instance of Robo-FTP.exe to run each scheduled script. The /nowait option allows Robo-FTP to launch a new Robo-FTP instance with your script and then immediately watch for another scheduling condition so no scripts are missed.

Your crontab file simply needs to contain the scheduling conditions and the names of the scripts you want to call like this:

 # Robo-FTP crontab.txt file
 # created by CronMaker

 # This will run at 12:00am every day
 0  0   *   *   *       script_1.s

 # This will run at 12:01am every day
 1  0   *   *   *       script_2.s

Even if script_1.s takes longer than one minute to run, script_2.s will still run as scheduled.

Warning

This technique will only work with the XE or Enterprise editions of Robo-FTP.

Robo-FTP Standard Edition is limited to running two simultaneous instances of Robo-FTP.exe. This technique requires running a minimum of three simultaneous instances to successfully avoid a scheduling collision:

  • The instance that runs your looping CRON script
  • The instance running the first script
  • The instance running the second script which otherwise would have been skipped if the first script were still running

The XE Edition currently enables you to run 16 simultaneous instances and the Enterprise Edition allows an unlimited number of simultaneous instances.


  1  :loop 
  2  WORKINGDIR "C:\Program Files\Robo-FTP"
  3  ;; wait for scheduled event (using "crontab.txt")
  4  CRON
  5  ;; launch a new Robo-FTP instance to run the task script
  6  exec "Robo-FTP.exe" /nowait /passargs "-s" %nextcmd
  7  ;; loop to wait for next event
  8  GOTO loop

Browse complete list of scripts

Need help figuring out where to start?

Our sales staff is available to answer product questions and help you determine if Robo-FTP is a good match for your project.

Call Now: (512) 345-2211