Page 1 of 1

Schedule to enable and disable interface in mikrotik

Posted: Sat Mar 03, 2018 8:55 am
by zakho1983
Hello
I want to enable an interface in mikrotik at 20:00 and disable it at 8:00 all days
Any one have this script to help me

Best regards

Sent from my TA-1021 using Tapatalk


Re: Schedule to enable and disable interface in mikrotik

Posted: Sat Mar 03, 2018 12:45 pm
by CZFan
/system scheduler
add disabled=no interval=1d name="Disable Either??" on-event="/interface disable [find name="ether??"]" \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=jun/21/2017 start-time=08:00:00

add disabled=no interval=1d name="Enable Either??" on-event="/interface enable [find name="ether??"]" \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=jun/21/2017 start-time=20:00:00

Re: Schedule to enable and disable interface in mikrotik

Posted: Sat Mar 03, 2018 1:30 pm
by zakho1983
Dear name of interface is lan4
And in all days weekly i like do this

Sent from my TA-1021 using Tapatalk


Re: Schedule to enable and disable interface in mikrotik

Posted: Sat Mar 03, 2018 10:29 pm
by haik01
Use scheduler. Not the script.

I did this for my kids (after 20:00h no internet on eth4).... Works perfectly.

In System, Scheduler add a new scheduler. Set start date, time etc....

In the white box below with name "on event": /interface disable 3

The number 3 should be changed to the interface number of the Ethernet interface you want to disable.

Re: Schedule to enable and disable interface in mikrotik

Posted: Sun Mar 04, 2018 9:58 am
by zakho1983
Use scheduler. Not the script.

I did this for my kids (after 20:00h no internet on eth4).... Works perfectly.

In System, Scheduler add a new scheduler. Set start date, time etc....

In the white box below with name "on event": /interface disable 3

The number 3 should be changed to the interface number of the Ethernet interface you want to disable.
Hello can i have your email to contact with u if you can help me to do it together? Thanks

Sent from my TA-1021 using Tapatalk


Re: Schedule to enable and disable interface in mikrotik

Posted: Sun Mar 04, 2018 12:08 pm
by pe1chl
In the white box below with name "on event": /interface disable 3

The number 3 should be changed to the interface number of the Ethernet interface you want to disable.
This is incorrect advice! Do not use it!
Instead, use the method shown by CZfan.
(of course the ?? in his example should be changed to 4 in this case)

Re: Schedule to enable and disable interface in mikrotik

Posted: Tue Dec 04, 2018 12:34 am
by abjaterza
As said by other members, just to clarify:

Code: Select all

/interface disable 3


where the 3 is the actual name of the interface as you can see it in the Interface list - by default ether1, ether2, and so on.

Re: Schedule to enable and disable interface in mikrotik

Posted: Tue Dec 04, 2018 2:08 pm
by pe1chl
NO!! don't do that!
Use the [find name="xxx"] construct.

Re: Schedule to enable and disable interface in mikrotik

Posted: Tue Dec 04, 2018 2:17 pm
by nescafe2002
or by name:

/interface disable lan4

Re: Schedule to enable and disable interface in mikrotik

Posted: Tue Jun 30, 2020 4:26 pm
by koolandrew
Can someone please correct my scritpt. I am trying to turn off wifi at night, which i recommend to everyone who has a wifi in their house, while they are sleeping, and turn it on automatically in the morning. I have followed the forums but unless i turn it off manually by using the "run script" command, it will not turn off. It turns on correctly.

1 name="DiisableWLAN" owner="admin"
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon
dont-require-permissions=no last-started=jun/29/2020 22:46:05 run-count=4
source=
interface wireless disable wlan1
interface wireless disable wlan2

2 name="EnableWLAN" owner="admin"
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon
dont-require-permissions=no last-started=jun/30/2020 06:30:00 run-count=16
source=
interface enable wlan1
interface enable wlan2

Schedule

[admin@MikroTik] /system scheduler> print
Flags: X - disabled
# NAME START-DATE START-TIME INTERVAL ON-EVENT RUN-COUNT
0 DisableWLAN jun/14/2020 22:40:00 1d DisableWLAN 17
1 EnableWLAN jun/15/2020 06:30:00 1d EnableWLAN 16
[admin@MikroTik] /system scheduler>

As mentioned it never starts at the start-time selected.

Re: Schedule to enable and disable interface in mikrotik

Posted: Wed Jul 01, 2020 12:32 am
by FRANKMUNOZ
Can someone please correct my scritpt. I am trying to turn off wifi at night, which i recommend to everyone who has a wifi in their house, while they are sleeping, and turn it on automatically in the morning. I have followed the forums but unless i turn it off manually by using the "run script" command, it will not turn off. It turns on correctly.

1 name="DiisableWLAN" owner="admin"
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon
dont-require-permissions=no last-started=jun/29/2020 22:46:05 run-count=4
source=
interface wireless disable wlan1
interface wireless disable wlan2

2 name="EnableWLAN" owner="admin"
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon
dont-require-permissions=no last-started=jun/30/2020 06:30:00 run-count=16
source=
interface enable wlan1
interface enable wlan2

Schedule

[admin@MikroTik] /system scheduler> print
Flags: X - disabled
# NAME START-DATE START-TIME INTERVAL ON-EVENT RUN-COUNT
0 DisableWLAN jun/14/2020 22:40:00 1d DisableWLAN 17
1 EnableWLAN jun/15/2020 06:30:00 1d EnableWLAN 16
[admin@MikroTik] /system scheduler>

As mentioned it never starts at the start-time selected.

Friend, try esot and let us know:

/interface disable [find name="wlan "]
delay 36000;
/interface enable [find name="wlan "]


ELDONCITO.

Re: Schedule to enable and disable interface in mikrotik

Posted: Wed Jul 01, 2020 4:41 pm
by koolandrew
I have trieid the following, all without success

/interface disable [find name="wlan "]

/interface disable [find name="wlan"]

/interface disable wlan1

/interface disable wlan1
/interface disable wlan2

The last two work when i hit run script. And it turns back on in the morning without doing anything.

Any ideas from any, as this is super frustrating...as is way too often with Mikrotik

Re: Schedule to enable and disable interface in mikrotik

Posted: Wed Jul 01, 2020 5:17 pm
by CZFan
Below will disable all interfaces where name contains "wlan"
/interface disable [find where name~"wlan"]
Then it seems you have a spelling mistake in the script name, so correct this and should work

1 name="DiisableWLAN" owner="admin"

Re: Schedule to enable and disable interface in mikrotik

Posted: Wed Jul 01, 2020 5:49 pm
by koolandrew
Thanks very much CZfan...i never saw it...i hope you are well in South Africa and staying healthy...

I have to be honest, when i think about it, i have had so many issue with Mikrotik wireless, especially with Apple products trying to connect over the last ten years, that i often give up for years at a time. I am using a CAP dual band, and i was hoping to use it instead of a Ubiquiti for my customersi but i still cannot connect specific devices to the 5g network...at least they can connect to something..which is better than my experience with Mikrotik HAP AC lite...where i cannot get Apple to connect at all.

Re: Schedule to enable and disable interface in mikrotik

Posted: Thu Jul 02, 2020 1:12 am
by CZFan
Personally can't recall if I ever had issues with devices connecting to eithe 2 / 5 Ghz, except in very noisy areas where neighbors wifi routers interfered so much with each other that the client devices failed to connect,