From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: bryan.mills@lynx.co.uk Newsgroups: gmane.os.tru64.managers Subject: SUMMARY:RE: Help with script Date: Wed, 05 Jun 2002 15:44:50 +0100 Sender: tru64-unix-managers-owner@ornl.gov Message-ID: NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1023289379 31264 127.0.0.1 (5 Jun 2002 15:02:59 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 5 Jun 2002 15:02:59 +0000 (UTC) Return-path: Original-Received: from sws1.ctd.ornl.gov ([160.91.20.101]) by main.gmane.org with smtp (Exim 3.33 #1 (Debian)) id 17FcJO-000889-00 for ; Wed, 05 Jun 2002 17:02:58 +0200 Original-Received: (qmail 13635 invoked by uid 5); 5 Jun 2002 14:42:32 -0000 Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 13627 invoked from network); 5 Jun 2002 14:42:32 -0000 Original-Received: from unknown (HELO emroute2.cind.ornl.gov) (128.219.159.41) by 0 with SMTP; 5 Jun 2002 14:42:32 -0000 Original-Received: from emroute2.cind.ornl.gov (LOCALHOST [127.0.0.1]) by emroute2.cind.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0GX800K5OM6VID@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Wed, 05 Jun 2002 10:42:31 -0400 (EDT) Original-Received: from mailsrv02.lynx.co.uk (mailhost.lynx.co.uk [194.203.251.189]) by emroute2.cind.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0GX8002QBM6T2Z@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Wed, 05 Jun 2002 10:42:31 -0400 (EDT) Original-Received: from mailhost.lynx.co.uk (unverified) by mailsrv02.lynx.co.uk (Content Technologies SMTPRS 4.2.5) with SMTP id for ; Wed, 05 Jun 2002 15:47:16 +0100 Original-To: tru64-unix-managers@ornl.gov X-Mailer: TFS Secure Messaging /222000000/223042434/223004594/223091115/ X-Mailer: Version 4.71 Build 102 Xref: main.gmane.org gmane.os.tru64.managers:448 X-Report-Spam: http://spam.gmane.org/gmane.os.tru64.managers:448 Enough !!!!!!! Thanks to the overwhelming responses to this one. Obviously a lot of people have been here before! Gold star on this one goes to Dr Tim Cutts for suggesting a hook into perl. It was close - but needed rob@thedeskopposite.co.uk to rework the syntax a little. Final answer that I'm going with is, ps -eo,cmd | perl -ne 'print if /\sPROGNAME\s/' Regards, Bryan. -----Original Message----- From: bryan.mills@lynx.co.uk [SMTP:bryan.mills@lynx.co.uk] Sent: Wednesday, June 05, 2002 2:43 PM To: tru64-unix-managers@ornl.gov Subject: UPDATE:RE: Help with script -------------------------------------------------------------------------- -- Okay, So there are two distinct camps on this topic. First, grep for the process name, if it exists then exit. Second, write a temporary lock file at the top of the scriptand check that when starting the duplicate script. I have problems with both of these. grep for the process name PROGRAM1 will find anything in the process list called PROGRAM1. If there were two cron entries, PROGRAM and PROGRAM1 then grep for PROGRAM when PROGRAM1 is running will foul things up. The lock file idea fine, but if the script crashes / system gets rebooted and leaves the file in place then jobs won't start because of the existance of the lock file. Using the pid may combat this, but our server goes a long time without reboots and the risk is there that the pid will roll over. What would work for me is being able to interrogate the ps list and look for specific process names, not using grep. That way, PROGRAM would be different to PROGRAM1. Any ideas if I can do anything along these lines ? Regards, Bryan. -----Original Message----- From: bryan.mills@lynx.co.uk [SMTP:bryan.mills@lynx.co.uk] Sent: Wednesday, June 05, 2002 10:18 AM To: tru64-unix-managers@ornl.gov Subject: Help with script -------------------------------------------------------------------------- -- We have many jobs started from the cron. Occasionally we end up with duplicates because the previous execution hasn't completed in time. Does anyone have a script that will check for itself before running, and 'exit 0' if a previous instance is in the process list. Bryan. This message is intended only for the use of the person(s) ("The intended Recipient(s)") to whom it is addressed. It may contain information which is privileged and confidential within the meaning of applicable law. If you are not the intended recipient, please contact the sender as soon as possible. The views expressed in this communication are not necessarily those held by LYNX Express Limited. This message is intended only for the use of the person(s) ("The intended Recipient(s)") to whom it is addressed. It may contain information which is privileged and confidential within the meaning of applicable law. If you are not the intended recipient, please contact the sender as soon as possible. The views expressed in this communication are not necessarily those held by LYNX Express Limited. This message is intended only for the use of the person(s) ("The intended Recipient(s)") to whom it is addressed. It may contain information which is privileged and confidential within the meaning of applicable law. If you are not the intended recipient, please contact the sender as soon as possible. The views expressed in this communication are not necessarily those held by LYNX Express Limited.