Concurrent Script Execution

<< Click to Display Table of Contents >>

Navigation:  Robo-FTP User's Guide > Script Programming > Select Topics in Script Programming >

Concurrent Script Execution


Multiple instances of Robo-FTP can process a single script file concurrently. This allows one multi-purpose script to be used for numerous similar tasks that share core functionality (see Multi-Purpose Scripts). The ability to process a single script file in concurrent instances also means that is possible for accidental simultaneous execution to occur. Some script operations could cause severe problems if executed concurrently.


Imagine, for example, a script that uploads files to a remote server and then deletes the local copies. Now suppose that a third-party scheduling tool is used to launch Robo-FTP and run this script every five minutes. This will work fine if each script execution always completes before the next instance is launched. However, if two instances of Robo-FTP were processing this script at the same time then unexpected errors or even data loss could occur when the first instance attempts to delete a file that the second instance is busy uploading.


This scenario could happen if the first script does not complete on time due to a temporary loss of network connectivity, high system CPU load, abnormal file transfer size or some other unexpected circumstance. Sometimes it is possible to eliminate the need to launch multiple instances by rewriting the script logic to run in a loop as a Windows Service. Another option is to launch Robo-FTP with the -r command line switch. This switch causes Robo-FTP to verify that there is not another instance of Robo-FTP already started with the -r switch that is currently processing the exact same script file. If such an instance is found, the new instance can either terminate immediately or wait for the first instance to complete.


With a script scheduled to launch every five minutes you might choose to simply terminate the newer instance since it will be launched again in five more minutes anyway. Use the "abort" option with the -r switch to achieve this result. The following command line shows -s switch for specifying a script file and the -r switch to specify what happens if another instance is currently processing the same script.


robo-ftp.exe -s "move2ftp.s" -r "abort"


This behavior is also available for scripts launched with the CALL or CHAIN commands by using the /waitifrunning option, for example:


CHAIN "move2ftp.s" /waitifrunning=abort


If skipping a script execution is possible but undesirable you may specify the maximum number of seconds to wait. In our example of the script launched every five minutes, you might be willing to wait up to four minutes (240 seconds) for the previous instance to complete before giving up and terminating the new instance.


robo-ftp.exe -s "move2ftp.s" -r 240


Use the "infinite" wait option when skipping any scheduled execution is unacceptable but concurrent script execution could cause problems.


robo-ftp.exe -s "move2ftp.s" -r "infinite"


The "infinite" option must be used carefully because it has the potential for allowing too many simultaneous instances. For example, if the script needs six minutes to complete but is scheduled to run every five minutes with an infinite wait, the number of running Robo-FTP.exe processes will gradually increase until the software license concurrent instance limit is reached or system resources are exhausted.



Software License Limits

The number of simultaneous instances of Robo-FTP.exe may be limited by the type of software license purchased by your organization. Once the simultaneous instance limit is reached, no additional instances may be launched until at least one of the running instances terminates. The maximum instance cap can cause intermittent scheduling issues when jobs do not run because previous scripts do not complete as quickly as expected. Concurrent instance limitations based on the software license may be easily resolved by upgrading the license. Please contact our Sales Team for pricing and availability.  



See also: Command Line Switches, Scheduling File Transfers With Robo-FTP, Programming Service Scripts