Community discussions

MikroTik App
 
dhiaahmed
newbie
Topic Author
Posts: 44
Joined: Sat Mar 31, 2018 1:05 pm

script scheduler

Fri Jul 09, 2021 11:55 am

Hello everyone, I have a script and I need it to be run between two specific times for example, between 23:00:00pm to 05:00:00. I couldn't do that in mikrotik scheduler. Is there a way to do this?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: script scheduler

Fri Jul 09, 2021 12:00 pm

Be more clear, also on topic title: "script scheduler", what?
Set it to 3am do not suffice?
 
msatter
Forum Guru
Forum Guru
Posts: 2897
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: script scheduler

Fri Jul 09, 2021 12:39 pm

You have to generate a random time in the scrip you schedule. Then use that delay to wait that random time before executing the rest of the script.

The only thing random in ROS is OTP in Certificates.
 
dhiaahmed
newbie
Topic Author
Posts: 44
Joined: Sat Mar 31, 2018 1:05 pm

Re: script scheduler

Fri Jul 09, 2021 12:54 pm

Be more clear, also on topic title: "script scheduler", what?
Set it to 3am do not suffice?
what I mean is I want the script to be run form 23:00:00 pm to 05:00:00 am with 00:15:00 interval after that I don't want it to be run utile 23:00:00 pm the next day. can I do it with
/system scheduler
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: script scheduler

Fri Jul 09, 2021 2:00 pm

I haved also think that (random execution), but I have prefered to ask....

The only thing random in ROS is OTP in Certificates.
False, and overcomplicate,
search my post for random numbers.
viewtopic.php?f=9&t=175453&p=858629
Last edited by rextended on Fri Jul 09, 2021 2:12 pm, edited 3 times in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: script scheduler

Fri Jul 09, 2021 2:03 pm

what I mean is I want the script to be run form 23:00:00 pm to 05:00:00 am with 00:15:00 interval after that I don't want it to be run utile 23:00:00 pm the next day.
Why you do not provide this details at start?

Schedule a scheduler al 23:00 than schedule the activation of the other scheduler, scheduled every 15 min,
and schedule another scheduler at 05:00 to disable the scheduled scheduler every 15 min.

Or more simply check at the start, inside the scheduled script, if the time are between 23:00 and 05:00
 
dhiaahmed
newbie
Topic Author
Posts: 44
Joined: Sat Mar 31, 2018 1:05 pm

Re: script scheduler

Sat Jul 10, 2021 2:24 pm

what I mean is I want the script to be run form 23:00:00 pm to 05:00:00 am with 00:15:00 interval after that I don't want it to be run utile 23:00:00 pm the next day.
Why you do not provide this details at start?

Schedule a scheduler al 23:00 than schedule the activation of the other scheduler, scheduled every 15 min,
and schedule another scheduler at 05:00 to disable the scheduled scheduler every 15 min.

Or more simply check at the start, inside the scheduled script, if the time are between 23:00 and 05:00
Thank you so much for your fast replies, would you please check if this script is correct because I don't have much experience in writing scripts:
global tm 23:00:00;;
global nt [system clock get time];
if ($nt >= 23:00:00 || $nt <= 05:00:00) do={system scheduler enable [find where name=night];system scheduler disable [find where name=sharing] } else={system scheduler disable [find where name=night];system scheduler enable [find where name=sharing]}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: script scheduler  [SOLVED]

Sat Jul 10, 2021 3:15 pm

You have mixed the 2 proposed solution,

1st solution without complicated scripts:

You can do copy & paste, the scripts are ready if your other scheduers are really called "night" and "sharing"

Supposing that "nigth" and "sharing" are another two scheduler scheduled every 15 minutes.

Create one scheduler than at 23:00 without any Formula 1 eh?... ops... any forumla do:
/system scheduler
disable sharing
enable night

and on ANOTHER scheduer at 05:00:00 do:
/system scheduler
disable night
enable sharing
 
dhiaahmed
newbie
Topic Author
Posts: 44
Joined: Sat Mar 31, 2018 1:05 pm

Re: script scheduler

Mon Jul 12, 2021 3:23 pm

I hope that mikrotik will add a field in the scheduler allowing scripts to be run during a specific period of time

Who is online

Users browsing this forum: rogerioqueiroz and 21 guests