Skip to content
MikroTik RouterOS Docs

Basic Scheduler and Scripts

For the impatient: here’s the 30-second version.

# Create and schedule a daily backup script
/system script add name=daily-backup source="/system backup save name=auto-backup"
/system scheduler add name=daily-backup-job start-time=00:00:00 interval=1d on-event=daily-backup

This guide demonstrates how to create scripts and schedule them on MikroTik RouterOS for automated tasks.

  • A MikroTik router running RouterOS 7.x or later
  • Access to the router via SSH, WinBox, or WebFig

Create a script that logs the current date and time:

/system script add name=log-time source=":log info \"Scheduled check at \$[/system clock get time]\"" comment="Time logging script"

Create a script that generates a configuration backup:

/system script add name=daily-backup source="/system backup save name=auto-backup" comment="Daily backup script"

Schedule the logging script to run every hour:

/system scheduler add name=hourly-log interval=1h on-event=log-time comment="Run log-time every hour"

Schedule daily backup at midnight:

/system scheduler add name=daily-backup-job start-time=00:00:00 interval=1d on-event=daily-backup comment="Daily backup at midnight"
/system script print

Expected Output:

Flags: I - invalid
# NAME OWNER POLICY RUN-COUNT LAST-STARTED
0 log-time admin read,write 5 jan/17/2026 14:00:00
1 daily-backup admin read,write 1 jan/17/2026 00:00:00
/system scheduler print

Expected Output:

Flags: X - disabled
# NAME START-DATE START-TIME INTERVAL ON-EVENT
0 hourly-log jan/17/2026 00:00:00 1h log-time
1 daily-backup-job jan/17/2026 00:00:00 1d daily-backup
/system script run log-time
/log print where message~"Scheduled check"

Symptoms: Scheduled task never executes, no log entries.

Causes & Solutions:

  1. Syntax errors in script - Test script manually:

    /system script run log-time

    If error appears, fix the script source.

  2. Scheduler disabled - Check scheduler status:

    /system scheduler print

    Look for X (disabled) flag. Enable if needed.

  3. Wrong script name in scheduler - Verify on-event matches script name exactly.

Symptoms: Script executes (run-count increases) but expected action doesn’t occur.

Causes & Solutions:

  1. Permission issues - Check script policy:

    /system script print detail where name=daily-backup

    Ensure script has required policies (read, write, policy, test, etc.)

  2. Variable scope issues - Local variables don’t persist. Use global for cross-script data.

  3. Silent errors - Add logging to script for debugging:

    :log info "Script started"
    # ... commands ...
    :log info "Script completed"

Symptoms: Script runs at unexpected times.

Causes & Solutions:

  1. System clock wrong - Verify NTP is configured:

    /system clock print
    /system ntp client print
  2. Start-time not set - For specific times, set both start-time and interval:

    /system scheduler set daily-backup-job start-time=00:00:00
  3. Timezone issues - Check timezone setting:

    /system clock print

Symptoms: Backup script runs but no files appear.

Causes & Solutions:

  1. Disk full - Check available space:

    /file print
    /system resource print
  2. Path issues - Verify file destination:

    /file print where name~"backup"
  3. Filename collision - Use unique names with date:

    /system script set daily-backup source=":local date [/system clock get date]; /system backup save name=(\$date . \"-backup\")"