How to add cron job on Asuswrt Merlin Wifi Router

How can I add or delete cron jobs on my wifi router powered by Asuswrt Merlin firmware? How do I add cron job on Asuswrt Merlin Wifi router using command line?

Introduction: Asuswrt-Merlin is an enhanced version of Asuswrt, the firmware used by Asus’s modern wifi routers. It is a third party alternative firmware for Asus routers, with a special emphasis on tweaks and fixes rather than radical changes or collecting as many features as possible.

How to add cron job on Asuswrt Merlin Wifi Router

You need to use the cru command to list, delete, or add new cron jobs.

What is a cron on Linux?

Cron allows Linux and Unix users to run commands or scripts at a given date and time. You can schedule scripts to be executed periodically. Cron is one of the most useful tools in a Linux or UNIX like operating systems. The cron service (daemon) runs in the background and constantly checks the /etc/crontab file, and /etc/cron.*/ directories. It also checks the /var/spool/cron/ directory.

cru command syntax to add, list, and delete cron jobs

The syntax is pretty simple:

Add a new cron job

cru a {id} min hour day month week command

  • id – Unique ID for each cron job
  • min – Minute (0-59)
  • hour – Hours (0-23)
  • day – Day (0-31)
  • month – Month (0-12 [12 is December])
  • week – Day of the week(0-7 [7 or 0 is Sunday])
  • command – Script or command name to schedule.

List cron jobs

cru l

Delete cron job

cru d {id}


Let us add cron job on Asuswrt Merlin Wifi router to ping gateway every 1 hour, run:
cru a pinggw "0 * * * * /bin/ping -c 10 -q"
Above cron job will run /bin/ping command that sends only 10 pings and only display output at start.
To list current jobs run:
cru l
To delete current jobs run:
cru d pinggw
Verify it:
cru l
cru command to list delete add cron job on Asuswrt Merlin Wifi Router

How to scheduled tasks/ cron jobs after rebooting the router

Due to a small amount of storage on a router you need to store your cron job as a script using cru command.

Create a script called services-start

Type the following cd command:
# cd /jffs/scripts
Edit/update a file named services-start file i.e. /jffs/scripts/services-start

# This cript get called after all other system services 
# have been started at boot on router
# ---------------------------------------------------------
# Sample cron job to install after reboot
cru a pinggw "0 * * * * /bin/ping -c 10 -q"
# Run my usb backup script every day at midnight 
cru a backup "0 0 * * * /jffs/scripts/"

Sample /jffs/scripts/ file displayed using the cat command:
cat /jffs/scripts/
Sample outputs:

# Purpose: Backup data to connected external USB 3.x hard disk
# Author: Vivek Gite under GPL version 2.x or above
# -------------------------------------------------------------
# GRAB files from my NFS server to external USB connected to this router
rsync -az -Hh --delete --numeric-ids ${nUSER}@${nSERVER}:${SRC} ${DEST}

Make sure you set executable permission using the chmod command:
chmod a+rx /jffs/scripts/services-start
chmod a+rx /jffs/scripts/

Enable boot time support for /jffs/scripts/

Support for these scripts stored under /jffs/scripts/ must be enabled, under Administration -> System on the webui:
Enable user scripts


And there you have it, I just add cron job on Asuswrt Merlin Wifi Router. You can create scheduled tasks using the standard crond service that runs on the router. You can put your cron tasks in /var/spool/cron/crontabs/. The file must be named “admin” as this is the name of the system user. Note that this location resides in RAM, so you would have to put your cron script somewhere such as in the jffs partition such as /jffs/scripts. A boot time copy it to /var/spool/cron/crontabs/ using an init-start user script. However, a simple way to manage your cron jobs is through the included “cru” command as described here. You can then put your “cru” commands inside a user script to re-generate your cron jobs at boot time. See official project help page for more info here and here.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Yaris T Jan 11, 2021 @ 16:09

    This was really clear and useful, thank you!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum