Sky18
March 17, 2018, 3:22pm
1
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!
JB172
March 17, 2018, 3:39pm
2
Sky18
March 17, 2018, 3:50pm
3
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.
pe1chl
March 17, 2018, 4:50pm
4
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)
Sky18
March 17, 2018, 6:07pm
5
Perfect, pe1chl! Thanks very much.
So simple and works as wanted..
Script:
:global StopCollectOnlineTime false;
...
:do {
...
} while=(!$StopCollectOnlineTime)
Terminal:
[admin@MikroTik-hEX] > :set $StopCollectOnlineTime true;