System information

Manual:System/Scheduler
151
Manual:System/Scheduler
Applies to RouterOS: 2.9, v3, v4
Summary
The scheduler can trigger script execution at a particular time moment, after a specified time interval, or both.
Properties
interval (time; default: 0s) - interval between two script executions, if time interval is set to zero, the script is
only executed at its start time, otherwise it is executed repeatedly at the time interval is specified
name name) - name of the task
on-event (name) - name of the script to execute. It must be presented at /system script
run-count (read-only: integer) - to monitor script usage, this counter is incremented each time the script is
executed
start-date (date) - date of the first script execution
start-time (time) - time of the first script execution
startup - execute the script 3 seconds after the system startup.
Notes
Rebooting the router will reset run-count counter.
If more than one script has to be executed simultaneously, they are executed in the order they appear in the scheduler
configuration. This can be important if one scheduled script is used to disable another one. The order of scripts can
be changed with the move command.
If a more complex execution pattern is needed, it can usually be done by scheduling several scripts, and making them
enable and disable each other.
if scheduler item has start-time set to startup, it behaves as if start-time and start-date were set to time 3 seconds after
console starts up. It means that all scripts having start-time=startup and interval=0 will be executed once each time
router boots.
Examples
We will add a task that executes the script log-test every hour:
[admin@MikroTik] system script> add name=log-test source=:log message=test
[admin@MikroTik] system script> print
0 name="log-test" source=":log messgae=test" owner=admin run-count=0
[admin@MikroTik] system script> .. scheduler
[admin@MikroTik] system scheduler> add name=run-1h interval=1h
on-event=log-test
[admin@MikroTik] system scheduler> print
Flags: X - disabled