Sunday, June 20, 2010

Activate the cron daemon on a DroboFS

I recently purchased a DroboFS NAS from DataRobotics. The device runs a minimal Marvell Linux OS on top of a low power ARM CPU (ARM926EJ-S).

The DroboFS supports third party development through the DroboApps platform. This allows end users to compile ARM applications using the GNU tool chain and run them on their DroboFS. On top of this these applications can be run as services using a small service API provided by DroboApps.

A number of DroboApps are available to enable dormant services on the DroboFS including the SSH, HTTP and FTP servers.

The DroboFS ships with a cron daemon tucked away at /usr/sbin/crond however there is no DroboApp available to enable the daemon. To rectify this I have written a small DroboApp script to activate the cron daemon at boot.

To get cron running as a service you'll need to do the following:
  1. Enable DroboApps on your DroboFS.
  2. Install the Dropbear SSH DroboApp.
  3. SSH into your DroboFS
  4. Create a directory for the cron DroboApp:
    mkdir /mnt/DroboFS/Shares/DroboApps/crond
  5. Save the following into your cron DroboApp directory
    # ------------------------------------------------------------
    # for cron DroboApp
    # Exposes the crond binary existing on the DroboFS as a 
    # DroboApps service.
    # ------------------------------------------------------------
    # Binaries used
    DATE="/bin/date +%Y:%m:%d-%H:%M:%S" # Nicely formatted date
    # Load the DroboApps service functions
    . /etc/service.subr
    # Required DroboApps variables
    prog_dir=`dirname \`realpath $0\``
    name="crond"                    # service name
    version="1.14.2"                # program version
    pidfile=${prog_dir}/ # location of pid file
    logfile=${prog_dir}/crond.log # location of log file
    # Start crond
      # Start the service
      # Create the pidfile
      pid=`$PS | $GREP $CROND | $GREP -v grep | $AWK '{print $1}'`
      $ECHO $pid > $pidfile
    case "$1" in
        $ECHO "`$DATE` Started cron service" >> $logfile    
        $ECHO "`$DATE` Stopped cron service" >> $logfile    
        sleep 3
        $ECHO "`$DATE` Restarted cron service" >> $logfile    
        $ECHO "Usage: $0 [start|stop|restart|status]"
        exit 1
  6. Restart your DroboFS.
Now the cron daemon is running from boot on your DroboFS. To add tasks for the cron daemon to run you will need to SSH into your DroboFS and run the following:
mkdir -p /var/spool/cron/crontabs
crontab -e
I hope someone finds this helpful.

2010-06-24: Edit added "mkdir -p /var/spool/cron/crontabs" Thanks pimvanderzwet


Anonymous said...

Troy this was very helpful and saved me a couple of ours of research. I got an error on the crontab -e however:

# crontab -e
crontab: chdir(/var/spool/cron/crontabs): No such file or directory

Creating the directory spool/cron/crontabs under /var fixed this. Perhaps I have an other version of the droboFS?

Now I'm trying to find the reboot command to shutdown my drobo over night.

Troy Test 1234 said...

I'll add the correction I had forgotten about creating the directory.
Also I think the command your looking for is /sbin/poweroff

Unknown said...

"I hope someone finds this helpful."

Yes I did. Thanks a ton!

Unknown said...

Thanks for this post, it was really helpful!

Anonymous said...

Really helpful...

Post a Comment