Crond

From WebOS Internals
Jump to navigation Jump to search

Enabling Stock Cron

The GPS_Tracking guide had a nice bit about enabling crond on the Pre. It looks like its already pre-installed, just not set up to start. You will need to edit /etc/event.d/mod-crond (don't modify the existing crond startup-script) to enable cron to start. The settings should look like this:

# -*- mode: conf; -*-

# jobfile for busybox crond, with pre-start commands to create the
# directory and files it wants by default.  That there's not 'start
# on' stanza is intentional: it's for development use only.  We can
# turn it on later if we need it, e.g. to keep the clock synced.  It
# does work.

start on stopped configure
stop on started start_update

respawn

exec /usr/sbin/crond -f -L /var/log/crond

pre-start script
    mkdir -p /var/spool/cron/crontabs
    ln -sf /etc/cron/crontabs/root /var/spool/cron/crontabs/root
end script

A few notes here. Unlike the Dropbear and other scripts I make my upstart scripts so that essential services don't stop when the device exists runlevel 2. This seems to shutdown these services whenever the device locks. I prefer that my upstart services stop only when the updater runs. Also I have made cron log to a separate file under /var/log so that it can be monitored better.

One thing to note about the standard script for cron on the Pre is that the /var/spool/cron/crontabs directory is created every time the process runs and a symlink to /etc/cron/crontabs/root is created. To my surprise this file does not exist. So we need to create it:

sudo mkdir -p /etc/cron/crontabs
sudo sh -c 'echo > /etc/cron/crontabs/root'

Now to start up crond:

sudo -i initctl start crond

Alternative (ipkg-opt) Method

crond is a system that allows command to be run at specified intervals.

Do not use the built in crontab -e as it is overwritten on each boot.

Optware has cron available as an installable package, and using /opt/etc/cron.d/ for cron files will not conflict with any Palm files.

sudo -i 
mount -o remount,rw /
ipkg-opt update
ipkg-opt install cron
/opt/bin/crontab -e
# Add script and intervals here
mount -o remount,ro /

This does not seam to work when the phone's screen turns off. I tried it plugged in for 2 min then unplugged and turned the screen off for 2 min,*/1 * * * echo `date` >> sleep.log and got:

# cat sleep.log 
Wed Jul 1 18:27:01 CDT 2009
Wed Jul 1 18:28:01 CDT 2009
Wed Jul 1 18:30:16 CDT 2009  ## this is when i turned the screen back on, seams to play catch up
Wed Jul 1 18:30:16 CDT 2009