Cron

Unfortunately the White Light version of Twonky server doesn't come with cron installed.
However, optware does allow you to install it:

/opt/bin/ipkg install cron

Optware helpfully tells you to "Remember that the system crontab file is "/opt/etc/crontab"."

Get cron to start on boot:

ln -s /opt/etc/init.d/S10cron /etc/init.d/S10cron

Update: Cheakamus (moc.sumakaehc|yaj#moc.sumakaehc|yaj) 2010-12-29

I tried the optware installation of vixie cron on my whitelight and ran into file permission problems I couldn't resolve. Upon further investigation I found that Dillon's cron (crond) was already installed but not enabled. To see if crond is installed try and run it:

~ # /usr/sbin/crond
crond: /var/spool/cron/crontabs: No such file or directory
~ #

If it returns that it can't find the crontabs directory then crond is installed and you can continue. Otherwise it will return with the following and, well, sorry:

~ # /usr/sbin/crond
-sh: /usr/sbin/crond: not found
~ #

I removed vixie cron and wrote the following rc script to enable crond. Install it in /etc/init.d/S99crond, set permissions to 755 and run it. It will create a template crontab in /etc/crontab. To configure scheduled events edit /etc/crontab per normal crontabs and restart crond.

(inspired by http://martybugs.net/wireless/openwrt/cron.cgi)

#!/bin/sh

# Script to enable crond (Dillon's cron) on My Book whitelight (WWLXN-WDH1NC)
#                                                                               
# Since /var/spool links to /tmp the default crontabs location in               
# /var/spool/cron/crontabs will get blown out on reboot. Instead we'll
# map the crontabs to /etc/crontabs                    
#                                                      
# Put this script in /etc/init.d/S99crond and chmod 755

check_crontabs() {
        if test ! -d /etc/crontabs ; then
                echo "Creating /etc/crontabs"
                mkdir /etc/crontabs
                echo "# crond control file for root (system)" > /etc/crontabs/root
                echo "# Restart crond after editing (/etc/init.d/S99crond restart)" >> /etc/crontabs/root
                echo "# m h dom mon dow   command" >> /etc/crontabs/root
                echo "# Uncomment next line and restart crond to test" >> /etc/crontabs/root
                echo "#* * * * * touch /tmp/crontab.test" >> /etc/crontabs/root
                ln -sf /etc/crontabs/root /etc/crontab
        fi
}

is_running() {
        PID=`ps aux | grep "crond -c \/etc\/crontabs" | grep -v grep | sed 's/^ *//' | cut -f 1 -d ' '`
        if test -z $PID ; then
                return 0
        else
                return 1
        fi
}

start() {
        check_crontabs
        echo -n "Starting crond: "
        is_running
        if test $? -eq 0 ; then
                /usr/sbin/crond -c /etc/crontabs
                touch /var/lock/crond
                echo "OK"
        else
                echo "crond is already running"
        fi
}       

stop() {
        echo -n "Stopping crond: "
        is_running
        if test $? -eq 1 ; then
                killall crond 
                rm -f /var/lock/crond
                echo "OK" 
        else
                echo "crond is not running"
        fi
}

restart() {
        stop
        start
}       

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart|reload)
                restart
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart}"
                exit 1
esac

exit $?
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License