[GRLUG] Running 'date' in an init script- weirdness

Raymond McLaughlin driveray at ameritech.net
Tue Jan 8 13:40:00 EST 2008


LUG nuts:
I have written a simple init script, getmyip, for my laptop, the core of
which is as follows:
    echo -n $(/bin/date)..>>/var/log/IP.log
    /usr/bin/w3m -dump whatsmyip.org |grep "Your IP Address is"\
       >>/var/log/IP.log

I have symlinked the proper runlevel folders so that it runs last at
start up and first at shut down. (/etc/init.d/rc3.d/K01getmyip,
/etc/init.d/rc3.d/S22getmyip on Open SuSE 10.3).

It runs as expected on shutdown and produces a line in /var/log/IP.log
like this:

Tue Jan 8 10:08:06 EST 2008..         Your IP Address is ww.xx.yy.zz

but on startup it produces entries like this:

Tue Jan 8 10:09:25 EST 2008Tue Jan 8 10:09:53 EST 2008..            Your
IP Address is ww.xx.yy.zz

Notice the two dots after the date only appear once which indicates that
the echo-date line is not running twice, but rather the date command is
running a second time, always 17-18 seconds after the first.

I have added delays of up to 30 seconds to the start of the script, just
so any other startup processes that might affect the system clock can
finish. No change.

Also I have tried this script on a SuSE 10.3 virtual machine and it
works as expected, no problem.

This script serves it's purpose as it is, but I would like it to work
with less krufty looking output. Insights anyone?

TIA
Raymond McLaughlin


More information about the grlug mailing list