How to Disable Mikrotik Hotspot Users in Time [Mikrotik Scripting]
One of the most widely used areas of mikrotik is the use of hotspots. In some cases, hotspot users may need to be shut down automatically or automatically.
For these cases, let’s make a statement with the examples below.
First of all, it is necessary to make sure that the date and time of our mikrotik device are up to date and constantly updated. This plays an important role in the timing of the rule.
Important: Be sure to review the article required to install the SNTP service.
1 – Mikrotik Hotspot users between 00:00 and 09:00 in the morning to be passive users and user input to occur.
Script sequence required for users to be passive at 23:59:59
1 2 | /system scheduler add interval=1d start-date=apr/26/2019 start-time=23:59:59 name=Hotspot_User_Close on-event="/ip hotspot user \n [:for i from=1 to= ([:len [find]]-1) do={ set disabled=yes $i }]" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |

Script sequence required for users to be activated at 09:00:00
1 2 | /system scheduler add interval=1d start-date=apr/26/2019 start-time=09:00:00 name=Hotspot_User_Open on-event="/ip hotspot user\n [:for i from=1 to= ([:len [find]]-1) do={ set disabled=no $i }]" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |

2 – Mikrotik Hotspot users want to clear a specific time, I do not want to delete each registered user one by one, you can use the following script for the question.
1 2 | /system scheduler add interval=1d start-date=apr/26/2019 start-time=04:00:00 name=Hotspot_User_Cleaning on-event="/ip hotspot user \n [:for i from=1 to= ([:len [find]]-1) do={ remove $i }]" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |

3 – Cleaning of registered users in Mikrotik Hotspot Cookies (not required if the profile is defined in timeout)
1 2 | /system scheduler add interval=1d start-date=apr/26/2019 start-time=04:00:00 name=Hotspot_Cookies_Cleaning on-event="/ip hotspot cookies \n [:for i from=0 to= [:len [find]] do={ remove $i }]" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon |
