Help with script for 2x WAN failover

Hi there,
I’ve been playing with RouterOS for a few months and am trying to use a script to change the route distance on 2x DHCP clients to perform WAN failover between interfaces ether1 and lte1.

The script is based on this:
https://wiki.mikrotik.com/wiki/Improved_Netwatch

If I run the scripts manually, everything seems to work properly in my tests. However, when I schedule the scripts via the scheduler, I am not having much luck.

My scripts and scheduler are setup as follows:

You can see by the image, there are 2 scripts – ‘testup’ and ‘testdown’. I have both set in the scheduler to run every 5 seconds, as recommended in the “Improved Netwatch” link from above. I’m having a few issues:

  1. Look at the Scheduler window at the top – it says both schedules have run almost an equal number of times. Now look at the 2 scripts – ‘testup’ has run 358 times. ‘testdown’ has only run 40 times.
  2. The LOG function I am using in the script is no longer working.
  3. This is the main problem – if I change ‘testup’ to ping 1.2.3.4 to simulate a down WAN on ether1, it changes the route distance properly. The issue is that ‘testdown’ doesnt seem to run via the scheduler. If I manully click the RUN button in the ‘testdown’ script page or run it using /system script run testdown, it works properly and changes the route distances back.

I’m very new to scripting, and am definitely not a rOS professional yet. However, I’m hoping to get some points or tips from the community to perhaps help me figure out the issues I’m having with this setup.

Any help is appreciated. Thanks!

Do not duplicate the posts.
https://forum.mikrotik.com/viewtopic.php?t=120966

Sorry!