Schedule & script for Microtik

I have the following four scripts which will enable and disable the various ISP’s Each one is set to a separate interface.

[code]/system script
add name=EnableISP1 policy=ftp,reboot,read,write,policy,test,winbox,password,sniff source=“interface pppoe enable pppoe-out1”

add name=DisableISP1 policy=ftp,reboot,read,write,policy,test,winbox,password,sniff source=“interface pppoe disable pppoe-out1”

add name=EnableISP2 policy=ftp,reboot,read,write,policy,test,winbox,password,sniff source=“interface pppoe enable pppoe-out2”

add name=DisableISP2 policy=ftp,reboot,read,write,policy,test,winbox,password,sniff source=“interface pppoe disable pppoe-out2”[/code]

Now the scheduler is where I’m lost.

I need to trigger the above scripts at certain times, weekdays and not on weekends.

EnableISP1 - Weekdays 6:00am till 6:00pm
EnableISP2 - Weekdays 6:00pm till 6:00am & all weekend

If anyone knows how please help me out.

Here’s the scheduler documentation:
http://wiki.mikrotik.com/wiki/Manual:System/Scheduler

It’s easy to trigger it everyday, but that’s not ideal. I could add a 5 day interval but how would that work if the router reboots? It would reset the day interval :s

/system scheduler add name="Enable ISP1" interval=12h start-time=06:00:00 add name="Disable ISP1" interval=12h start-time=17:59:50 add name="Enable ISP2" interval=12h start-time=18:00:00 add name="Disable ISP2" interval=12h start-time:05:59:50

An advanced way would be a script that runs every few seconds to check day & time then IF Monday > 06:00 < 18:00 then disable isp2 and enable isp1 etc.

This is a script I use for updating dynamic DNS: (runs every 5 minutes)

[code]##############Script Settings##################

:local NOIPUser “no-ip.com LOGIN”
:local NOIPPass “no-ip.com PASSWORD”
:local WANInter “MikroTik Router WAN Interface Name”

###############################################

:local NOIPDomain “$NOIPUser.no-ip.org
:local IpCurrent [/ip address get [find interface=$WANInter] address];
:for i from=( [:len $IpCurrent] - 1) to=0 do={
:if ( [:pick $IpCurrent $i] = “/”) do={
:local NewIP [:pick $IpCurrent 0 $i];
:if ([:resolve $NOIPDomain] != $NewIP) do={
/tool fetch mode=http user=$NOIPUser password=$NOIPPass url=“http://dynupdate.no-ip.com/nic/update\3Fhostname=$NOIPDomain&myip=$NewIP” keep-result=no
:log info “NO-IP Update: $NOIPDomain - $NewIP”
}
}
}[/code]

some examples: http://wiki.mikrotik.com/wiki/Manual:Scripting-examples

Hmm never scehduled anything on mikrotik, pity they dont just stick to a standard crontab config on the routers considering they run a linux kernel.

yay got it

[code]/system scheduler
add interval=1d name=peak on-event=start_peak policy=reboot,read,write,policy,test,password,sniff,sensitive start-date=aug/07/2014 start-time=06:00:00
add interval=1d name=offpeak on-event=start_offpeak policy=reboot,read,write,policy,test,password,sniff,sensitive start-date=aug/07/2014 start-time=18:00:00
add interval=1w name=week on-event=enable_switch policy=reboot,read,write,policy,test,password,sniff,sensitive start-date=aug/11/2014 start-time=00:00:00
add interval=1w name=weekend on-event=disable_switch policy= reboot,read,write,policy,test,password,sniff,sensitive start-date=aug/09/2014 start-time=00:00:00

/system script
add name=start_peak policy=reboot,read,write,policy,test,password,sniff,sensitive source=
"/interface pppoe-client disable pppoe-out2
/interface pppoe-client enable pppoe-out1"
add name=start_offpeak policy=reboot,read,write,policy,test,password,sniff,sensitive source=
"/interface pppoe-client disable pppoe-out1
/interface pppoe-client enable pppoe-out2"
add name=enable_switch policy=reboot,read,write,policy,test,password,sniff,sensitive source="/system scheduler enable [/system scheduler find name=peak] /system scheduler enable [/system scheduler find name=offpeak]“
add name=disable_switch policy=reboot,read,write,policy,test,password,sniff,sensitive source=”/system scheduler disable [/system scheduler find name=peak] /system scheduler disable [/system scheduler find name=offpeak]"[/code]

What this does:

4 schedules: 1st one runs the peak times, 2nd runs off-peak times, 3rd one disables the peak & off-peak schedules on a weekend. 4th one enables the peak & offpeak schedules after the weekend.