Community discussions

MikroTik App
 
zakho1983
just joined
Topic Author
Posts: 5
Joined: Fri Mar 11, 2016 12:09 am

Schedule to enable and disable interface in mikrotik

Sat Mar 03, 2018 8:55 am

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

 
User avatar
CZFan
Forum Guru
Forum Guru
Posts: 2098
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Krugersdorp (Home town of Brad Binder)
Contact:

Re: Schedule to enable and disable interface in mikrotik

Sat Mar 03, 2018 12:45 pm

/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
 
zakho1983
just joined
Topic Author
Posts: 5
Joined: Fri Mar 11, 2016 12:09 am

Re: Schedule to enable and disable interface in mikrotik

Sat Mar 03, 2018 1:30 pm

Dear name of interface is lan4
And in all days weekly i like do this

Sent from my TA-1021 using Tapatalk

 
haik01
Member
Member
Posts: 404
Joined: Sat Mar 23, 2013 10:25 am
Location: Netherlands

Re: Schedule to enable and disable interface in mikrotik

Sat Mar 03, 2018 10:29 pm

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.
 
zakho1983
just joined
Topic Author
Posts: 5
Joined: Fri Mar 11, 2016 12:09 am

Re: Schedule to enable and disable interface in mikrotik

Sun Mar 04, 2018 9:58 am

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

 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Schedule to enable and disable interface in mikrotik

Sun Mar 04, 2018 12:08 pm

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)
 
abjaterza
just joined
Posts: 9
Joined: Sat Jul 09, 2011 2:20 am

Re: Schedule to enable and disable interface in mikrotik

Tue Dec 04, 2018 12:34 am

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.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Schedule to enable and disable interface in mikrotik

Tue Dec 04, 2018 2:08 pm

NO!! don't do that!
Use the [find name="xxx"] construct.
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 897
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: Schedule to enable and disable interface in mikrotik

Tue Dec 04, 2018 2:17 pm

or by name:

/interface disable lan4
 
User avatar
koolandrew
newbie
Posts: 28
Joined: Tue Dec 06, 2011 7:20 pm
Location: Toronto
Contact:

Re: Schedule to enable and disable interface in mikrotik

Tue Jun 30, 2020 4:26 pm

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.
 
FRANKMUNOZ
newbie
Posts: 32
Joined: Mon Feb 24, 2020 12:59 am

Re: Schedule to enable and disable interface in mikrotik

Wed Jul 01, 2020 12:32 am

Friend, try esot and let us know:

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


ELDONCITO.
 
User avatar
koolandrew
newbie
Posts: 28
Joined: Tue Dec 06, 2011 7:20 pm
Location: Toronto
Contact:

Re: Schedule to enable and disable interface in mikrotik

Wed Jul 01, 2020 4:41 pm

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
 
User avatar
CZFan
Forum Guru
Forum Guru
Posts: 2098
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Krugersdorp (Home town of Brad Binder)
Contact:

Re: Schedule to enable and disable interface in mikrotik

Wed Jul 01, 2020 5:17 pm

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"
 
User avatar
koolandrew
newbie
Posts: 28
Joined: Tue Dec 06, 2011 7:20 pm
Location: Toronto
Contact:

Re: Schedule to enable and disable interface in mikrotik

Wed Jul 01, 2020 5:49 pm

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.
 
User avatar
CZFan
Forum Guru
Forum Guru
Posts: 2098
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Krugersdorp (Home town of Brad Binder)
Contact:

Re: Schedule to enable and disable interface in mikrotik

Thu Jul 02, 2020 1:12 am

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,
 
ChristianGrundy
just joined
Posts: 2
Joined: Fri Oct 23, 2020 8:45 pm

Re: Schedule to enable and disable interface in mikrotik

Thu Aug 18, 2022 6:28 pm

NO!! don't do that!
Use the [find name="xxx"] construct.
This seems good advice, but I am just wondering why is the construct better than just the name?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Schedule to enable and disable interface in mikrotik

Thu Aug 18, 2022 6:38 pm

This was a reply to someone who used a number (3) to refer to the interface. Don't do that, it won't work.
Using a name instead of [find name="xxx"] should work the same. But it is not allowed everywhere, so I tend to use the universal [find name="xxx"] construct.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Schedule to enable and disable interface in mikrotik

Thu Aug 18, 2022 7:41 pm

Never use directly the .id (3) on script, can change everytime (and often exist only after "print")

examples code

# Wrong, because .id must not be used
/interface disable 3

# Both wrong, because wlan1 exist only as string, and can be misunderstanded
/interface disable wlan1
/interface disable "wlan1"

# Work for single / all
/interface disable [find name="wlan1"]
/interface disable [find name~"wlan"]

# Correct syntax for single / all
/interface disable [find where name="wlan1"]
/interface disable [find where name~"wlan"]

# "Perfect" for single / all, because if you change interface name, the script still work....
/interface disable [find where default-name="wlan1"]
/interface disable [find where default-name~"wlan"]

# Correct way for disable / enable all wireless for night
/interface wireless disable [find]
/interface wireless enable [find]

and another consideration ...

Why do some scripts, to be re-called in the scheduler (which a hidden "return/enter" can block),
and not directly put the script text in the scheduler???
Doing double duty, for nothing, only increases the chance of making mistakes...
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19099
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Schedule to enable and disable interface in mikrotik

Fri Aug 19, 2022 4:01 pm

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.
My experience as well koolandrew, you would have to pry my MT router from my dead cold hands but I willingly gave away my capacs, except for one, for testing purposes.
I use tplink eap245 and then 6660HD and no issues with apple gear (mostly IOs phones).

(nice script err sorry, system scheduler solution there CZFAN)
 
User avatar
koolandrew
newbie
Posts: 28
Joined: Tue Dec 06, 2011 7:20 pm
Location: Toronto
Contact:

Re: Schedule to enable and disable interface in mikrotik

Tue Aug 30, 2022 5:19 pm

Unfortunately, albeit a little late, i have had so many issues as well with Apple devices, i cannot begin to tell you. And the customers dont want to know about it, but nor does Mikrotik, unfortunately.

I have a CAP AC sitting in our office, in the box. I would be super excited to deploy it as well.

Who is online

Users browsing this forum: bertus, kiloon, rarriazu, Vyizis and 93 guests