How to stop a script in endless loop?

Hi guys,

is there a possibility to stop a script in endless loop?

I have a script that should run all the time and start automatically after reboot.

something like this:

:do {
...
} while=( true )

But under certain conditions I want to interrupt it without removing it from “autostart” and rebooting the RB.

Any chance to do this?

Thanks!

check this: http://forum.mikrotik.com/t/command-to-interrupt-script-execution-in-if/21708/1

Thanks, JB172.

Interesting, but this is not what I need.

I want to stop the running script from “external” e.g. from the Terminal Window, or something like via the Task Manager in Windows.

instead of while (true) use a while condition that checks a global variable for equal/unequal some value.
then you can set the global variable from the terminal to stop the loop.
(of course you need to initialize it to another value before the loop)

Perfect, pe1chl! Thanks very much.

So simple :sunglasses: and works as wanted..

Script:

:global StopCollectOnlineTime false;
...
:do {
...
} while=(!$StopCollectOnlineTime)

Terminal:

[admin@MikroTik-hEX] > :set $StopCollectOnlineTime true;