i’m searching for a solution to prevent the execution of a script when it is still running. My first idea was to search for the script name with:
/system script job find where script=NameOfMyScript
But that is not enough sophisticated for me It would be great to get the name of the script that calls this command, but i can’t find a way to get that information automatically. Is there a way or variable to do that?
A semaphore (this variable thing) was my first idea, but it is very unstable as jarda says and you need at least another startup script that sets the variable to a fixed value at startup.
The next disadvantage is more source code and you need to set the variable back at every endpoint of the script. That is errorprone
I think i will do it with hard coded script names for now. I do not like it, but it is the less ugly way…
If anyone knows how to get the script name from within the script, please post it here!
# Variables - Part 1
:local ScriptName "gateway0-check"
# Script already running? If yes, log message and exit.
:if ([:len [system script job find where script=$ScriptName]] > 1) do={
:log info ($ScriptName . " - script still active. Termination of another execution.")
end
}
# Variables - Part 2
# ... rest of the script