|
From: H. D. L. <lea...@du...> - 2002-09-22 11:42:57
|
Hi,
I'll try again.
On 2002.09.22_18:19:39_+0000, H. D. Lee wrote:
> On 2002.09.22_13:00:44_+0000, Anders Åkesson wrote:
> > Hi!
> >
>
> Hi,
>
> > I have wondered why my firewall never updates it's hw or sys clock
> > although it should. I found that the updatetime script in
> > /etc/multicron-d doesn't work.
> >
> > updatetime () {
> >
> > [ -f /etc/default/rcS ] && . /etc/default/rcS
> > [ "$GMT" = "-u" ] && GMT="--utc"
> > if [ -n "`ps axc | grep xntpd`" ]; then
> > hwclock --systohc $GMT
> > else
> > [ "$lrp_DATE_SERVER" != "" ] \
> > && rdate -s $lrp_DATE_SERVER \
> > && sleep 2 && hwclock --systohc $GMT
> > fi
> > }
> >
> > This code will ALWAYS go into the first option of the if-statement.
> >
> > The length of "`ps axc | grep xntpd`" will always be non-zero because
> > 'grep xntpd' will be launched as a new process due to the pipe.
> >
>
> No, the shell will return the value from the grep appropriately. I
> haven't tested this with ash (the shell used by Bering). Only with ksh,
> so I may be wrong. Following commands prove my statement:
>
> $ ps axc | grep xntpd
> $ echo $?
> 1
This may be a wrong way to proof thing, as I state so in another mail
following this, in the same thread. But I could still see zero length of
string returned.
> $ ps axc | grep getty
> 494 tty1 S 0:00 getty
> 495 tty2 S 0:00 getty
> [...]
> $ echo $?
> 0
>
I have created a script just to test this:
$ cat try
#! /bin/sh
if [ -n "`ps axc | grep xntpd`" ]; then
echo "not zero."
else
echo "zero."
fi
if [ -n "`ps axc | grep getty`" ]; then
echo "not zero."
else
echo "zero."
fi
$ ./try
zero.
not zero.
As above, I am not running xntpd, but getty exist on the process list.
HTH
> CMIIW
>
> >
> > /Anders
> >
>
> --
> H. D. Lee
>
--
H. D. Lee
|