In the LuCI interface, under System >> Scheduled Tasks, enter (at the top):
# ┌───────────── minute (0–59); */5 every 5 minutes; */10 every 10 minutes # │ ┌───────────── hour (0–23) # │ │ ┌───────────── day of month (1–31) # │ │ │ ┌───────────── month (1–12 or JAN–DEC) # │ │ │ │ ┌───────────── day of week (0–7 or SUN–SAT, 0 and 7 = Sunday) # │ │ │ │ │ # * * * * * # # ENSURE ALL SCRIPTS HAVE A SHEBANG AT THE TOP, eg: #!/bin/sh # ENSURE ALL SCRIPTS HAVE BEEN MADE EXECUTABLE, eg: chmod +x /etc/YOUR SCRIPT.sh # # PLACE SCRIPTS IN /etc/ SO THEY SURVIVE FIRMWARE UPDATES, eg: # cat << 'EOF' > /etc/YOUR_SCRIPT.sh # {SCRIPT GOES HERE} # EOF # # EXAMPLE: # System configuration backup (SUNDAYS at 0415) 15 4 * * 0 /bin/sh /etc/backup_router.sh # # EXAMPLE # Compact memory if needed (Every 5 minutes) */5 * * * * /bin/sh -c /etc/memcompact.sh
If you need to run a process every x hours, you could do:
30 /5 * * *
… that runs at 0530, 1030, 1530, 2030… then starts over again at 0530, because the counter resets at midnight.
So, you can do this, instead:
45 * * * * [ $(( ($(date +%s) + 3) / 3600 % 5 )) -eq 0 ] && /your/process/here.sh
date +%s displays the number of seconds since 1970-01-01. The cron job runs once an hour, but only actually executes your process if the interval (5, in this case) is evenly divisible into number of seconds since 1970-01-01 / 3600 (modulo 5). Note that we add 3 seconds to the Epoch Seconds, just to be sure that if you’ve set it up to run at 0 (top of the hour), if cron wakes up a few milliseconds earlier than 0 (top of the hour), the cron job still runs. Because it rounds, the modulo-5 of hours since 1970-01-01 will equal 0 for the entire hour. Hence, you can set that 45 above to whatever you want. You can also set the modulo (5 in the example above) to whatever you want.
You can test it yourself by issuing the following at the CLI:
echo $(( (($(date +%s) + 5) / 3600) % 5 ))
And here’s a LibreOffice Calc spreadsheet that auto-updates to show when your process should run, so you can monitor it to ensure it’s starting alright.
DNS Dedup Timer.ods (473.2 KB)
Be sure to account for your time zone… change the +21600 in Cell A2.