Community discussions

MikroTik App
 
seidi
just joined
Topic Author
Posts: 4
Joined: Sat Nov 14, 2020 11:57 pm

Run command in specific timeframe

Sun Nov 15, 2020 12:02 am

Hello,

I am relativ new to Mikrotik. I want to run a script every minute but only between only between 03:00am and 04:00am.
When I see it correct the scheduler can run commands only in an intervall but not in a timeframe.

Does someone has an idea how a script should look like which I can execute with the scheduler every 2 minutes. I assume there is a way to make this script first check the time and then execute the command when it is between 3 and 4
 
User avatar
inteq
Member
Member
Posts: 406
Joined: Wed Feb 25, 2015 8:15 pm
Location: Romania

Re: Run command in specific timeframe

Sun Nov 15, 2020 7:25 pm

See if this helps:
:local time [/system clock get time];
:if ($time >= "03:00:00" || $time <= "04:00:00") do={ :log warning hammer time } 
 
seidi
just joined
Topic Author
Posts: 4
Joined: Sat Nov 14, 2020 11:57 pm

Re: Run command in specific timeframe

Sun Nov 15, 2020 7:37 pm

Hi,

do you think that I have to post here my own schript?

do={ :log warning hammer time } --> for exampe do={ script }
 
User avatar
inteq
Member
Member
Posts: 406
Joined: Wed Feb 25, 2015 8:15 pm
Location: Romania

Re: Run command in specific timeframe

Sun Nov 15, 2020 7:39 pm

Execute your command inside the do={ }
 
seidi
just joined
Topic Author
Posts: 4
Joined: Sat Nov 14, 2020 11:57 pm

Re: Run command in specific timeframe

Sun Nov 15, 2020 8:17 pm

I tried the following

put the following into a script

:local time [/system clock get time];
:if ($time >= "18:00:00" || $time <= "18:45:00") do={ ip ipsec active-peers kill-connections }

But it looks luike that the time frame is regocnizes and the command runs every time
 
User avatar
inteq
Member
Member
Posts: 406
Joined: Wed Feb 25, 2015 8:15 pm
Location: Romania

Re: Run command in specific timeframe

Sun Nov 15, 2020 11:31 pm

Just double checked and it seems RouterOS does not support this type of time calculation without extra math involved.

Who is online

Users browsing this forum: No registered users and 18 guests