How I Fixed Script Timeout Issues When Polling Multiple IPs with RouterOS

Hello

I was writing a RouterOS script to ping a list of IPs and log their status every few minutes but the script kept timing out after about 10–15 entries. :slightly_smiling_face: At first; I assumed it was a hardware performance issue but even on more powerful devices, the same timeout occurred. :upside_down_face:

It turns out that the loop & execution delay needed to be managed better within MikroTik’s limited scripting environment. :thinking:

After tweaking the loop using :delay and breaking the task into smaller chunks with scheduled executions, the script became much more stable. I also reduced timeout settings & added logging to trace exactly where the script was choking. This RouterOS Scripting Manual helped me understand how RouterOS handles long-running scripts internally. :thinking:

While working on this, I briefly confused RouterOS scripting with general-purpose languages and found myself reading about what is java, which, unlike RouterOS script, is object-oriented and runs on the JVM. :innocent:

Definitely reminded me how important it is to understand the limitations of each scripting environment. If anyone has tips on optimizing large script loops in RouterOS, I’d love to hear them!

Thank you !! :slightly_smiling_face:

Easy: do not use large scripts.

You didn’t explain why you’re doing these pings, but netwatch probably already does what you want with scripts, without too many problems.