Community discussions

MikroTik App
 
imirsay
just joined
Topic Author
Posts: 22
Joined: Fri Jul 28, 2023 12:47 pm

If the uptime was more than 1 minute

Thu Aug 01, 2024 3:45 pm

I want If the uptime was more than 1 minute, execute this command
/tool fetch url="https://api.telegram.org/bot6674120664: ... text=T1-Up"
 
holvoetn
Forum Guru
Forum Guru
Posts: 6940
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: If the uptime was more than 1 minute

Thu Aug 01, 2024 4:59 pm

Make script - on startup
First line: delay 60
And then your line.
 
imirsay
just joined
Topic Author
Posts: 22
Joined: Fri Jul 28, 2023 12:47 pm

Re: If the uptime was more than 1 minute

Thu Aug 01, 2024 7:34 pm

Make script - on startup
First line: delay 60
And then your line.
I don't want it to run late. I want the command to be executed with the condition that the uptime is more than one minute. That is, if the uptime was less, the command would not be executed.
 
holvoetn
Forum Guru
Forum Guru
Posts: 6940
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: If the uptime was more than 1 minute

Thu Aug 01, 2024 8:39 pm

Delay will take care of that.
No need to complicate things....

What's the difference between checking in a loop until one minute has passed or simply waiting 1 minute ?
What do you think is easier ?
The result is the same....
 
imirsay
just joined
Topic Author
Posts: 22
Joined: Fri Jul 28, 2023 12:47 pm

Re: If the uptime was more than 1 minute

Fri Aug 02, 2024 7:52 am

Delay will take care of that.
No need to complicate things....

What's the difference between checking in a loop until one minute has passed or simply waiting 1 minute ?
What do you think is easier ?
The result is the same....
I want use in netwach !
The difference is that the command is executed after a delay!
I want the command not to be executed if the up time was less
 
User avatar
tangent
Forum Guru
Forum Guru
Posts: 1675
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: If the uptime was more than 1 minute

Fri Aug 02, 2024 9:01 am

You’re not reading @holvoetn’s post carefully. His scheme will cause the script to run one minute after boot, as you asked. If the system goes down before then, it will be “cancelled,” hard.

It’s both elegant and correct.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10567
Joined: Mon Jun 08, 2015 12:09 pm

Re: If the uptime was more than 1 minute

Fri Aug 02, 2024 10:21 am

The difference is that the command is executed after a delay!
I want the command not to be executed if the up time was less
In netwatch, at least in RouterOS v7 you can specifiy a start delay and a startup delay in the netwatch command.
Check the documentation to find what it does.
 
Apachez
Member Candidate
Member Candidate
Posts: 147
Joined: Mon Jul 01, 2024 11:45 pm

Re: If the uptime was more than 1 minute

Fri Aug 02, 2024 8:12 pm

https://help.mikrotik.com/docs/display/ROS/Scheduler
Note: if scheduler item has start-time set to startup, it behaves as if start-time and start-date were set to time 3 seconds after console starts up. It means that all scripts having start-time is startup and interval is 0 will be executed once each time router boots. If the interval is set to value other than 0 scheduler will not run at startup
So if you put your script to be runned "on-boot" and in your script add a ":delay 57s;" it will be as close as possible to 1 minute after boot.

Or you can time how long it takes for the ROS itself to finish the boot on your particular device/model and then subtract 3 seconds (which is the on-boot delay for scheduling) along with the time it takes for the device to finish booting and put that as delay as first line in your script.
 
jaclaz
Forum Guru
Forum Guru
Posts: 2236
Joined: Tue Oct 03, 2023 4:21 pm

Re: If the uptime was more than 1 minute

Fri Aug 02, 2024 8:26 pm

Why do I have this deja vu feeling? :?:

Same poster, same question, same answers:
viewtopic.php?t=209273
 
Apachez
Member Candidate
Member Candidate
Posts: 147
Joined: Mon Jul 01, 2024 11:45 pm

Re: If the uptime was more than 1 minute

Sat Aug 03, 2024 9:21 am

Perhaps a case of asking the same question multiple times until she gets the answer she is looking for?
 
holvoetn
Forum Guru
Forum Guru
Posts: 6940
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: If the uptime was more than 1 minute

Sat Aug 03, 2024 10:18 am

Why do I have this deja vu feeling? :?:

Same poster, same question, same answers:
viewtopic.php?t=209273
I already had the feeling too I saw this recently with the same reluctance to accept the answer....
 
pe1chl
Forum Guru
Forum Guru
Posts: 10567
Joined: Mon Jun 08, 2015 12:09 pm

Re: If the uptime was more than 1 minute

Sat Aug 03, 2024 11:09 am

Well, the question is not very clear and the context is not clear at all, that is why the "wrong answers" that are not accepted to appear.
Above the clue is "I want use in netwach !" so the requirement apparently is not to have a command run exactly 1 minute after boot of the system, but to have a condition in a netwatch script that it should not run when the system is not up for at least a minute.
That is of course understandable... there are often false netwatch alerts because it fires before the system has been correctly initialized and all links have come up.
However, the netwatch functionality was improved in RouterOS v7 and now, the probing by netwatch does not start immediately after boot, but only after "startup-delay" which defaults to 5 minutes.
So the solution is easy: set startup-delay to 1 minute in the netwatch item, and it all works.
 
User avatar
infabo
Forum Guru
Forum Guru
Posts: 1508
Joined: Thu Nov 12, 2020 12:07 pm

Re: If the uptime was more than 1 minute

Sat Aug 03, 2024 12:05 pm

Classic. Explain the goal rather than an issue. It is a good advice for real life as well.
 
millenium7
Long time Member
Long time Member
Posts: 595
Joined: Wed Mar 16, 2016 6:12 am

Re: If the uptime was more than 1 minute

Mon Aug 05, 2024 6:57 am

Seems like a roundabout way to go about it, having to go to an external URL

Can achieve the same internally without reaching out to an external source
:if ([/system resource get uptime] > 00:01:00) do={:put "yes"}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12658
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: If the uptime was more than 1 minute

Mon Aug 05, 2024 12:37 pm

Seems like a roundabout way to go about it, having to go to an external URL

Can achieve the same internally without reaching out to an external source
Already wroted,
viewtopic.php?t=209273#p1085695

OP do not like the answers, so open again another thread for the same question....