Setup Optware Cron

January 15, 2015

I needed to run some daily tasks and didn’t feel like leaving my desktop computer on all day. I use an ASUS RT-N56U Wireless Router in my apartment.

After googling around a bit I found this guide for setting up cron jobs with this custom firmware. However, this firmware had problems communicating with my LEDENET/Mi Light/Limitless LED WiFi Bridge Controller Hub.

I went back to the stock firmware and installed optware on a cheap USB thumb drive using this guide. Be sure to format the drive to EXT 2! It will be a huge pain if you leave the drive formatted as fat32.

After I installed optware I ran the following commands to get optware cron working

# Install curl to get around Asus wget limitations
ipkg install curl

# Install cron from optware's repository
ipkg install cron

# Remove the old startup script
rm /opt/etc/init.d/S10cron

# Download my startup script that also fixes file permissions
curl -O /opt/etc/init.d/S10cron

# Restart the router

Cron throws an error if the crontab and cron.d scripts file permissions are anything other than RW by owner and the ASUS RT-N56U resets all files to 777 on reboot. My startup script explicitly sets the file permissions to what cron expects.

# Startup script for optware cron
# Fix file permissions
# Cron throws an error if these files are anything other than RW by owner
chmod 600 /opt/etc/crontab
chmod -R 600 /opt/etc/cron.d/
# Stop myself if running
[ -f ${PIDFILE} ] && kill `cat ${PIDFILE}`

Below is an example of the correct format for the optware crontab file

# /opt/etc/crontab example
# ---------- ---------- Default is Empty ---------- ---------- #
40 7 * * 1-5 admin /opt/etc/cron.d/ >> /opt/var/log/cron.log 2>&1

The nice part of using the optware cron instead of the built in cron.d service is any changes will survive firmware updates. Also, optware is needed to install the programs to complete any non-trivial task such as bash, netcat, seq, etc.