From owner-freebsd-questions Sun May 18 14:35:53 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id OAA13989 for questions-outgoing; Sun, 18 May 1997 14:35:53 -0700 (PDT) Received: from smtp.connectnet.com (smtp.connectnet.com [207.110.0.12]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id OAA13982 for ; Sun, 18 May 1997 14:35:49 -0700 (PDT) Received: from wink.connectnet.com (wink.connectnet.com [206.251.156.23]) by smtp.connectnet.com (8.8.5/Connectnet-2.2) with SMTP id OAA20880 for ; Sun, 18 May 1997 14:36:10 -0700 (PDT) Message-Id: <199705182136.OAA20880@smtp.connectnet.com> From: "That Doug Guy" To: "FreeBSD Questions" Date: Sun, 18 May 97 14:35:13 -0800 Reply-To: "That Doug Guy" Priority: Normal X-Mailer: PMMail 1.91 For OS/2 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Subject: Unusual cron behaviour Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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