Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Aug 97 15:30:35 -0800
From:      "Studded" <Studded@dal.net>
To:        "FreeBSD Questions" <FreeBSD-Questions@freebsd.org>
Subject:   Possible cron bug
Message-ID:  <199708112231.PAA19729@mail.san.rr.com>

next in thread | raw e-mail | index | archive | help
	I am working on an sh script to be run by cron every 5 minutes to
check and see if a certain process is running, and if it's not to start it
up.  I have a script that works just fine for this task, however on those
occasions that the process is not running and it needs to start it, I get
some unusual leftovers from cron that I would like to eliminate, or at
least verify to be non-harmful.  In the following script, adjkerntz is the
guinea pig process (since I don't want to kill the one I'm actually
testing for :), however the behaviour is the same.  System is
2.2.1-Release.  Here is the script:

#!/bin/sh

/bin/ps -ax | /usr/bin/grep [a]djkerntz

if [ $? != 0 ]; then
        /sbin/adjkerntz -i
fi

exit

Here is the cron job:

*/2     *       *       *       *    root  /bin/sh /home/root/test.sh

And here is the result from ps when it has to start the process:

 6591  ??  I      0:00.01 CRON (cron)
 6592  ??  Z      0:00.00  (sh)
 6598  ??  Is     0:00.01 /sbin/adjkerntz -i

	A kill for 6591 in this example also eliminates the zombie (sh)
process, and the ghost CRON thinger doesn't seem to have any adverse
affect on the system, however I don't want to take chances since the whole
point of this is to have it run safely unattended.  I've tried the script
with and without using an & to bg the process (although it shouldn't be
needed with a daemon like adjkerntz), and with and without the exit
statement.  I've also tried it on several other FreeBSD systems and with
different processes to start, and the result is always the same.  Also,
the CRON (cron) process takes up some small amount of memory (about 500
bytes).  I haven't had a chance to test long term if the amount of memory
used increases, since I don't have any systems that I can take chances
with right now.  

	I am not doing a send-pr yet since I'm still not sure this isn't
an error on my part, however I've researched everything I can find on
this, and haven't found any mention of the problem I'm describing here. 
If it would be better to send this to -bugs or do a send-pr, just let me
know.

Thanks,

Doug

Do thou amend they face,
	and I'll amend my life.
-Shakespeare, "Henry V"




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199708112231.PAA19729>