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.
lockfile.s
Lockfiles provide a simple way to limit access to a file, script, or process.
Consider the example where you have scheduled a script to run once every minute, but you are concerned about what happens if the script takes longer than a minute to run -- you don't want two copies of the script running at the same time. In that case, you might want Robo-FTP to silently exit and wait for the next minute to run again.
This sample script creates a temp file called "lockfile.txt" before it begins processing. It deletes the file when it is done.
The script checks for the existence of the lockfile before doing anything else. If the file exists, it means a copy of the script is still running, so it simply exits.
1 iffile "lockfile.txt" goto lockfile_exists
2 ; Lockfile does not exist, so
3 ; create one and begin processing
4 writefile "lockfile.txt" "processing"
5 ; Add script processing here
6
7 ; Processing is done, so
8 ; remove lockfile and exit
9 delete "lockfile.txt"
10
11 :lockfile_exists
12 ; If lockfile exists skip processing
13 ; and exit.
14 exit

