Date: Sun, 18 May 97 14:35:13 -0800 From: "That Doug Guy" <tiller@connectnet.com> To: "FreeBSD Questions" <FreeBSD-Questions@freebsd.org> Subject: Unusual cron behaviour Message-ID: <199705182136.OAA20880@smtp.connectnet.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 [ $? = 1 ] ; then /sbin/adjkerntz -i fi Here is the cron job: */2 * * * * root /home/root/test.sh And here is the result 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'm open to other ways to do the test for the process (that don't involve the .pid file), however I don't think that that part of the script is the problem, since I can do the test all day long and it won't cause that ghost CRON whether the test fails or succeeds. It's only when cron actually starts the process that I get that. The script works from the command line without problems as well. Finally, if anyone has a clever ways to stop cron from mailing me every 5 minutes to tell me it did nothing I'd love to hear them. Also, my apologies if I'm missing something painfully obvious here, I've read everything I could find and talked to several people who have a lot of experience with sh scripts, and they were just as mystified as I am. TIA, Doug
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705182136.OAA20880>