Community discussions

MikroTik App
 
doesnotexist9437
just joined
Topic Author
Posts: 5
Joined: Wed Mar 23, 2011 4:57 am

Scheduling two scripts

Thu Jul 14, 2011 4:28 am

If I want to run a script 5 times at 5:00, how would I schedule it?

In other words, how would I create the "while" statement for the event?
 
tjc
Member Candidate
Member Candidate
Posts: 276
Joined: Sun Jul 10, 2011 3:08 am

Re: Scheduling two scripts

Thu Jul 14, 2011 8:11 am

Why not just wrap the whole script in a for loop? http://wiki.mikrotik.com/wiki/Manual:Sc ... statements
:for cnt from=0 to=5 step=1 do={
  <your commands here>
}
Somebody correct me, since I'm not sure if that'll repeat 5 or 6 times. Is the to value included in the range or excluded?
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Scheduling two scripts

Thu Jul 14, 2011 3:02 pm

'to' is included, so it runs 6 times:
[user@rb750g] > :for loop from=0 to=5 do={ :put $loop }
0
1
2
3
4
5
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Scheduling two scripts

Fri Jul 15, 2011 1:46 am

Just check the run-count of a single scheduled script

<add scheduled script to run at 5:00 every day>
Script:
:if ([/system scheduler get <scheduler name> run-count] > 5) do={
   /quit
}

<rest of script to run>..
 
tjc
Member Candidate
Member Candidate
Posts: 276
Joined: Sun Jul 10, 2011 3:08 am

Re: Scheduling two scripts

Fri Jul 15, 2011 5:01 am

Ah, good point. Did they want the script to repeat 5 times when it was run or be limited to running 5 times. Your interpretation probably makes more sense.

Who is online

Users browsing this forum: sebol1204 and 44 guests