Thursday, May 17, 2012

Using cron to Start Monitor Program at Boot Time

The idea is to run the tcl program beaglegsm.tcl at boot time, using tclsh of course. To do this edit the root cron entries using the 'crontab -e' command. The crontab entries for root are as follows. Note the complete path entries for program script and log files.

30 * * * *    /usr/bin/ntpdate -b -s -u pool.ntp.org
@reboot /home/root/tcl-from-beaglebone/tcl/beaglegsm.sh >/home/root/tcl-\
          from-beaglebone/tcl/cronout.log

File beaglegsm.sh:

#!/bin/sh

cd /home/root/tcl-from-beaglebone/tcl/

sleep 120

while [ true ]; do
        echo "(`date`) Running beaglegsm.tcl"
        tclsh beaglegsm.tcl &>beaglegsm-tclsh.out
        insmod /lib/modules/3.2.13/kernel/drivers/net/usb/hso.ko
        echo "Beaglegsm.tcl exited. Delaying then restarting"
        sleep 120
done



The 120 second delay is to let the modem power up and be recognized by Linux as /dev/ttyHS0-3. If the program faults (due lately to the modem somehow timing out), the insmod tries to re-establish the /dev/ttyHS- device, but this feature is experimental and will likely go away soon. 

When power is disconnected and comes back up, the modem seems not to be recognized correctly. But, after a reboot command it seems to be recognized OK. I may add a reboot text message to reboot, and also have the unit do a reboot automatically when the modem is not recognized.
 
Since the beaglebone is off the network, ntp will not set the time, and since it has no clock, time will default to something like  'Fri Apr 13 16:43:26 EDT 2012'. I will try to fix this by having the unit set time on ceceipt of the first text message, getting the time from the date message field.

No comments:

Post a Comment