if router uptime is more

Here is a workaround if you still want to figure out the seconds since boot but again using a “delay 60s;” as first row in your script is much more efficient along with schedule that script as startup-script.


:global myUPTIMESEC "0";
:global myTIMEOUT "60";
while ($myUPTIMESEC < $myTIMEOUT) do={
    :local tmpUPTIME [/system resource get uptime];
    :local tmpWEEKS [:pick $tmpUPTIME 0 [:find $tmpUPTIME "w"]];
    :set tmpUPTIME [:pick $tmpUPTIME ([:find $tmpUPTIME "w"]+1) [:len $tmpUPTIME]];
    :local tmpDAYS [:pick $tmpUPTIME 0 [:find $tmpUPTIME "d"]];
    :set tmpUPTIME [:pick $tmpUPTIME ([:find $tmpUPTIME "d"]+1) [:len $tmpUPTIME]];
    :local tmpHOURS [:pick $tmpUPTIME 0 [:find $tmpUPTIME ":"]];
    :set tmpUPTIME [:pick $tmpUPTIME ([:find $tmpUPTIME ":"]+1) [:len $tmpUPTIME]];
    :local tmpMINUTES [:pick $tmpUPTIME 0 [:find $tmpUPTIME ":"]];
    :set tmpUPTIME [:pick $tmpUPTIME ([:find $tmpUPTIME ":"]+1) [:len $tmpUPTIME]];
    :local tmpSECONDS $tmpUPTIME;
    :set myUPTIMESEC [(($tmpWEEKS*604800)+($tmpDAYS*86400)+($tmpHOURS*3600)+($tmpMINUTES*60)+$tmpSECONDS)];
#    :put ("Seconds since boot: ".$myUPTIMESEC);
    :delay 1s;
}

For the above the myTIMEOUT is what timeout you wish and you should probably adjust that “:delay 1s;” in the end if you dont need a second resolution (for example if you want to run your script after 1 hour its sufficient to change that delay into “:delay 1m;” or so).