To list, delete, or add new cron jobs, you need to use the command:
cru
Add a new cron job:
cru a {id} min hour day month week command
List cron jobs:
cru l
Delete cron job:
cru d {id}
How to scheduled cron jobs after rebooting the router
Because of a small volume of storage on a router, you require to store your cron job as a script using "cru" command.
Create a script named "service-start"
Type the following command:
# cd /jffs/scripts
Edit/update a file named service-start file i.e. /jffs/scripts/service-start
#!/bin/sh # 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 142.108.1.123" # Run my usb backup script every day at midnight cru a backup "0 0 * * * /jffs/scripts/usb-backup-script.sh # ---------------------------------------------------------
Sample /jffs/scripts/usb-backup-script.sh file displayed using the "cat" command:
cat /jffs/scripts/usb-backup-script.sh
Sample outputs:
# --------------------------------------------------------- DEST="/tmp/mnt/sda1" nUSER="Ashu" nSERVER="162.154.1.153" SRC="/backups" # ---------------------------------------------------------
Note:
1) Set executable permission using the "chmod" command:
chmod a+rx /jffs/scripts/service-start
chmod a+rx /jffs/scripts/usb-backup-script.sh
2) Enable boot time support for /jffs/scripts/
Must be enabled, under Administration > System on the webui:
DONE!!