The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,364 other followers

Script job killer – MikroTik RouterOS

Posted by jpluimers on 2017/10/09

After reading [WayBackScript job killer – MikroTik RouterOS I put lines like these into a few of my frequently running scripts:

/system script environment get systemScriptJobCountTypeIsCommand
:global systemScriptJobCountTypeIsCommand

:local scriptsOfTypeCommandCount [$systemScriptJobCountTypeIsCommand];

:if ($scriptsOfTypeCommandCount > 4) do={
  $outputError value=("$scriptName; too many runnings commands ($scriptsOfTypeCommandCount); bailing out early");
  :return -1;

They in turn use this underlying function:

:local scriptName "Function.systemScriptJobCountTypeIsCommand.rsc"
/system script environment remove [ find where name="systemScriptJobCountTypeIsCommand" ];

:global systemScriptJobCountTypeIsCommand do={
  :local result [:len [/system script job find where type=command]];
#  :put "result=$result"
  :return $result;

## Example:
## /import scripts/Function.systemScriptJobCountTypeIsCommand.rsc
## :put [$systemScriptJobCountTypeIsCommand];


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: