Syed Jahanzaib Personal Blog to Share Knowledge !

December 7, 2011

Mikrotik Howto Add Schedule to Run the Script

To add schedule to run any specific script at specific scheduled time, Follow the steps Below.

1) First create the script
2) Schedule it to run it at desired time.

SCENARIO # 1 | Allow user JOHN access to internet in Lunch Timings Only . . .

You have created a rule that blocks user John internet access all the time (In this example, we disable user id JOHN, it can also be done via creating firewall rule to block access, but for this example we will use disable strategy), but you want him to use internet from 1:00pm til 2:00pm. You have to create two scripts, first that will disable the “Block user john rule” at 1 pm and the second script that will enable the “Block user john rule” at 2 pm.

Here is the “Block user john rule

/ppp secret add caller-id="" comment="" disabled=no limit-bytes-in=0 limit-bytes-out=0 local-address= name=john password=123 profile=default routes="Testing ID" service=any

Here are the Scripts examples in following screenshots.

Now ADD the following Scheduler to Execute both scripts at desired timing.

# Enable-User-John-Script at 1PM (Interval 1d so it may run every day)
# Disable-User-John-Script at 2PM (Interval 1d so it may run every day)


[admin@MikroTik] > /system script export
/system script
add name=disable-user-john-script policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/ppp secret disable john"
add name=enable-user-john-script policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/ppp secret enable john"


[admin@MikroTik] > /system scheduler export
/system scheduler
add comment="" disabled=no interval=1d name="Enable User JOHN at 1pm" on-event=Enable-user-john-script policy=reboot,read,write,policy,test,password,sniff,sensitive start-date=dec/07/2011 start-time=13:00:00
add comment="" disabled=no interval=1d name="Disable User JOHN at 2pm" on-event=Disable-user-john-script policy=reboot,read,write,policy,test,password,sniff,sensitive start-date=dec/07/2011 start-time=14:00:00

Another example on howto disable Web Proxy Access Rule.

SCENARIO # 2 | Block Access to Facebook, and Allow only in Lunch Timings

You have blocked access to social networking web sites Facebook and you want that users can access it only in Lunch timings, which is from 1:00pm till 2:00pm. I assume you are using Mikrotik web proxy [transparent mode], (If not, you can block the access via ip pool + firewall filter, adjust it accordingly, its only an example)

For example you have created an rule in web.proxy to block Facebook, (BLOCK-FB rule) which blocks Face-book site , example below

/ip proxy access
add action=deny comment=fb disabled=no

(Don’t forget the ‘comments’ in rule) and Now you want to Allow access to FB from 1:00 pm till 2:00 pm,
You have to create two Scripts, one that will disable the BLOCK-FB rule,
and second that will enable the BLOCK-FB rule.

Disable-fb-rule Script

/ip proxy access disable [find comment="fb"]

Enable-fb-rule Script

/ip proxy access enable [find comment="fb"]

OR you can Add scripts via following code in TERMINAL.

/system script
add name=disable-fb-rule-script policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/ip proxy access disable [find comment=\"fb\"]"
add name=enable-fb-rule-script policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/ip proxy access enable [find comment=\"fb\"]"

Now add schedule to Run “disable-fb-rule-script” to run at 1:00 pm Daily,
Add another schedule to Run “enable-fb-rule-script” to run at 2:00 pm Daily,

/system scheduler
add comment="" disabled=no interval=1d name="Disable fb rule schedule" on-event="disable-fb-rule-script"  start-date=dec/08/2010 start-time=01:00:00
add comment="" disabled=no interval=1d name="Enable fb rule schedule" on-event="enable-fb-rule-script"  start-date=dec/08/2010 start-time=02:00:00

SCENARIO # 3 | Reboot RB daily in  night

Following script will create a schedule, which will reboot RB daily in night at 1:00am.

/system scheduler
add comment="Reboot every 1 day" disabled=no interval=1d name=Reboot1d on-event="/system reboot" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive start-date=Nov/14/2012 start-time=01:00:00


  1. Hi….
    Thnx for your help. I m trying to restrict facebook in some IP and allow in some other IP in my network, is it possible? Please help


    Comment by Sanjoy — May 2, 2012 @ 5:21 PM

  2. pls sir, pls how can i allow everbody or users to browse from 1pm to 7am in the schedules time. thank u sir


    Comment by emmy — November 24, 2012 @ 9:30 PM

  3. Nice one but I have a different requirement just like above but regarding internet access in defined time interval.
    Scenario could be like below:

    We will have 3 different group : Group-1 includes some customers / Group 2 Includes some and Group-3 includes some.

    These 3 different group will have different time interval for internet access lets say gp-1 will have internet access from 6:am to 10am , after that internet block , likewise same for remaining 2 group.


    Comment by Shiva Thapa — January 21, 2013 @ 3:22 PM

    • Well It can be done by various ways. Either by create a FILTER rule that blocks specific IP ranges in specific TIME. Time can be define in the RULE by going to EXTRA tab.
      TIME option can be helpful to you, Because if you use TIME tab, then you wont have to configure the SCRIPTS and SCHEDULER.



      Comment by Syed Jahanzaib / Pinochio~:) — January 23, 2013 @ 11:19 AM

  4. Hello
    I am setting up a MikroTik Router on x86 machine.
    It is all set now and Im runing internet from it. it is getting internet from a PPPoE connection which is giving dynamic ip and so is its dhcp server. Now when my server restarts, it abort its previous connection and starts a new one on which it receives a new ip address hence screwing up the routing settings. What should i do to solve this problem.



    Comment by DragoTech Innovations PK — March 6, 2013 @ 3:24 PM

    • This is the default behavior of DHCP. Request your ISP to fix your IP so your routing dont get messed, you need static ip if you have particular need.
      Why you require fix ip anyway ? for hat service ?


      Comment by Syed Jahanzaib / Pinochio~:) — March 6, 2013 @ 7:53 PM

  5. Hi I am newbie ,I have to do wifi network at our school,as our requirement ,we need to do modify configuration for student with time schedule like (auto disconnect & auto reconnect ). Goal is student can not access internet in lecture time and can access internet after lecture time on student account ,Please help me Master !!!!


    Comment by Thuya — August 27, 2016 @ 11:09 AM

  6. Assalam O Allekum Brother
    i m running a pppoe server on RB-433UAH. i want to put connection date in comments and script find date in comments and macth system date than disable user


    Comment by Muhammed Azam Ghouri — January 6, 2017 @ 10:17 PM

  7. aoa
    bhai mujhe autologin ke script bnwani h plzz banwa dain gain


    Comment by hashir Mehmood — November 3, 2017 @ 3:23 AM

  8. can i use this in ppoe acount i want my ppoe client limit at 30days then it will disconnect not remove for me not going to his house to change his username and pass?


    Comment by Norodin C. Baer — April 27, 2019 @ 8:00 AM

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: