Disabling / enabling interface with scheduler?

How would I do this from the web interface? I’d love to be able to enable an interface at 5:30 Wednesdays and to disable it at 9:45 at night.

Since RouterOS doesn’t have a way to get the day of the week automatically, you’ll have to use a script like this one: http://wiki.mikrotik.com/wiki/Script_to_find_the_day_of_the_week, example below.

Go into System > Scripts, and create a new one. Name the script whatever and select all the Policies (there’s probably only a few that are actually needed). Paste this code and edit the interface name to match the one you want to enable/disable.

:local interface "ether2"

:local date [/system clock get date]

:local result ""
:local months [:toarray "jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec"]
:local monthtbl [:toarray "0,3,3,6,1,4,6,2,5,0,3,5"]
:local daytbl [:toarray "sun,mon,tue,wed,thu,fri,sat"]

:local month [:pick $date 0 3]
:local day [:pick $date 4 6]
:local dayc [:pick $date 5 6]
:local century [:pick $date 7 9]
:local year [:pick $date 9 11]
:local yearc [:pick $date 10 11]

:if ([:pick $date 4 5] = 0) do={:set day ($dayc)}
:if ([:pick $date 9 10] = 0) do={:set year ($yearc)}

:local sum 0
:set sum ($sum + (2 * (3 - ($century - (($century / 4) * 4)))))
:set sum ($sum + ($year / 4))
:set sum ($sum + $year + $day)
:for mindex from=0 to=[:len $months] do={
  :if ([:pick $months $mindex] = $month) do={:set sum ($sum + [:pick $monthtbl $mindex]) }
}
:set sum ($sum - (($sum / 7) * 7))
:set result [:pick $daytbl $sum]

:if ($result = "wed") do={
  :local time [:pick [/system clock get time] 0 5]
  :if ($time = "17:30") do={
    /interface enable $interface
  }
  :if ($time = "21:45") do={
    /interface disable $interface
  }
}

After saving the script, go into System > Scheduler and make a new entry. Start Date: Jan/01/1970, Start Time: 00:17:30, Interval: 1d 00:00:00, select all Policies, On Event: yourScriptName. Then add a second scheduler entry with Start Time: 00:21:45 and everything else the same.

So, then the 2 schedules will run the script at their respective times, and the script will detect the day and time and enable/disable the interface accordingly.

If you want to test the script before Wednesday, just edit the bottom section of the script, changing the $result from “wed” to “mon” or whatever day it is, and the times to whatever time you want it to change.

:if ($result = "wed") do={
  :local time [:pick [/system clock get time] 0 5]
  :if ($time = "17:30") do={
    /interface enable $interface
  }
  :if ($time = "21:45") do={
    /interface disable $interface
  }
}

I would have made it easier

System-Sheduler:
Name: enable-eth
Start Date: Jan/04/1970
Start Time: 05:30:00
Interval: 7d 00:00:00
On Event: /interface enable ether2
Policy: write,test,read



System-Sheduler:
Name: disable-eth
Start Date: Jan/04/1970
Start Time: 21:45:00
Interval: 7d 00:00:00
On Event: /interface disable ether2
Policy: write,test,read

I like your solution, much simpler! I think start date needs to be Jan/07/1970 to be on a Wed