I need a script that executes commands if router uptime is more than one minute
Help me please
delay 57s;
https://help.mikrotik.com/docs/display/ROS/Scheduler
Perhaps add it as a startup-script in the scheduler which will run it 3 seconds after boot but the first line in your script is something like:
Code: Select alldelay 57s;
Then have the rest of your code which gives that the script starts 3 seconds after boot then sits and wait for 57 seconds before executing the rest of the script which gives that you have runned whatever you wish to run 1 minute after boot.
: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;
}
{
:local upsec [:tonum [/system resource get uptime]]
:if ($upsec > 60) do={
# ...script code...
}
}
{
:if ([/system resource get uptime] > "00:01:00") do={
# ...script code...
}
}
You do not specify RouterOS version. For v7 Simply...
if the number is > 60... is more than 1 minutes that the device is up...Code: Select all{ :local ups [:tonum [/system resource get uptime]] :if ($ups > 60) do={ # ...script code... } }
for v6, since is just a string...Code: Select all{ :if ([/system resource get uptime] > "00:01:00") do={ # ...script code... } }
I need a script that executes commands if router uptime is more than one minute
Help me please
I need checked uptime. If the uptime was less, the command would not be executed
This command only has a delay
What you write is absolutely not in the OP, what are you making up?
I need a script that executes commands if router uptime is more than one minute
Help me please
And on the other post that isa reply to your post:I need checked uptime. If the uptime was less, the command would not be executed
This command only has a delay
I do not read at any point about "loop" or "script being runned 1 minute after boot" etc.
However, if it were really that, a wait of 57 seconds would simply be enough, as you have already written...
But he didn't like your answer, so I'm assuming that's NOT the case.
Of course, if the OP could explain better.................................
I need a script that executes commands if router uptime is more than one minute
Which is fulfilled when you run 3s after boot and first wait 57s.Here is the usecase:
I need a script that executes commands if router uptime is more than one minute
You really didnt read the OP (original post) did you?
Here is the usecase:
I need a script that executes commands if router uptime is more than one minute
You really didnt read the OP (original post) did you?
Here is the usecase:
Mine is clearly more in line with the (incomplete) request.
So what?
No "loop" or "wait until" required.
Don't make things up.
He asked exactly "script that executes commands if router uptime is more than one minute" and there are no further details.
Don't have a limited view, the scripts are NOT only present in the scheduler,
but trivially it could also be something that must happen in the pppoe script or in the DHCP script (incomplete list)
that if for some reason the interface is not yet active, the execution fails .
And you can't start certain scripts late at startup because they are not interactive with parameters readable only by the pppoe or DHCP scripts.