From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Cohen, Andy" Newsgroups: gmane.os.tru64.managers Subject: SUMMARY: find out one's own PID when running from cron Date: Fri, 19 May 2006 12:28:37 -0400 Message-ID: <9D592DB37A92234AB635C5585D2D08190430BB8C@cobra.pc.cognex.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1148056167 1402 80.91.229.2 (19 May 2006 16:29:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 19 May 2006 16:29:27 +0000 (UTC) Original-X-From: tru64-unix-managers-owner-gotm-tru64-unix-managers=m.gmane.org@sws1.ctd.ornl.gov Fri May 19 18:29:17 2006 Return-path: Envelope-to: gotm-tru64-unix-managers@gmane.org Original-Received: from sws1.ornl.gov ([160.91.1.101]) by ciao.gmane.org with smtp (Exim 4.43) id 1Fh7qR-0004yk-Uc for gotm-tru64-unix-managers@gmane.org; Fri, 19 May 2006 18:28:59 +0200 Original-Received: (qmail 12191 invoked by uid 49509); 19 May 2006 16:28:45 -0000 Original-Sender: tru64-unix-managers-owner@ornl.gov Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 12181 invoked by uid 49501); 19 May 2006 16:28:45 -0000 Original-Received: from 160.91.4.110 by sws1 (envelope-from , uid 49491) with qmail-scanner-1.25 (clamdscan: 0.83/743. spamassassin: 3.0.2. Clear:RC:0(160.91.4.110):SA:0(-2.6/5.0):. Processed in 0.313912 secs); 19 May 2006 16:28:45 -0000 X-Spam-Status: No, hits=-2.6 required=5.0 Original-Received: from emroute3.ornl.gov (160.91.4.110) by sws1.ornl.gov with SMTP; 19 May 2006 16:28:44 -0000 Original-Received: from emroute3.ornl.gov (localhost [127.0.0.1]) by emroute3.ornl.gov (PMDF V6.2-1x9 #31038) with ESMTP id <0IZI002MITRW1V@emroute3.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Fri, 19 May 2006 12:28:44 -0400 (EDT) Original-Received: from VIRUSCAN-DAEMON.emroute3.ornl.gov by emroute3.ornl.gov (PMDF V6.2-1x9 #31038) id <0IZI00302TRQI7@emroute3.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Fri, 19 May 2006 12:28:43 -0400 (EDT) Original-Received: from cognex.cognex.com (cognex-out.cognex.com [198.232.29.228]) by emroute3.ornl.gov (PMDF V6.2-1x9 #31038) with ESMTP id <0IZI000IMTRQAM@emroute3.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Fri, 19 May 2006 12:28:38 -0400 (EDT) Original-Received: from atlantis.pc.cognex.com (atlantis.pc.cognex.com [10.10.160.5]) by cognex.cognex.com (8.12.11/8.12.11) with ESMTP id k4JGSbC8021087 for ; Fri, 19 May 2006 12:28:37 -0400 (EDT) Original-Received: from cobra.pc.cognex.com ([10.10.160.30]) by atlantis.pc.cognex.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 19 May 2006 12:28:37 -0400 Original-To: Tru64 Managers X-Envelope-from: Andy.Cohen@cognex.com X-MIMEOLE: Produced By Microsoft Exchange V6.5.7226.0 Thread-Topic: SUMMARY: find out one's own PID when running from cron Thread-Index: AcZ7YBO0O59Bl5njQ36EGr+nvo/olA== Content-class: urn:content-classes:message X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on email.ornl.gov X-Spam-Level: X-Qmail-Scanner-MOVED-X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00 autolearn=ham version=3.1.1 X-MS-Has-Attach: X-MS-TNEF-Correlator: X-OriginalArrivalTime: 19 May 2006 16:28:37.0779 (UTC) FILETIME=[48118630:01C67B61] Xref: news.gmane.org gmane.os.tru64.managers:8914 Archived-At: I've already got a summary: If your script is sh or ksh, so $$ will contain the PID of your running script. So I just did a: export MY_PID=3D$$ And it worked PERFECTLY! Thanks to Jean-Marc Vincent at HP. Andy ORIGINAL QUESTION =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Hi, =20 I have a shell script that runs from cron. It needs to check if there are still previous runs of itself still running and if so it needs to kill them (but not kill itself). I can get the shell script to find all currently running copies of this script but the list includes the current one but I only want to kill the previous ones. How do I get the shell script to find out its own PID? I can do it at the command line but when I try to do it when the script runs from cron I get an error message: =20 ps: no controlling terminal =20 Thanks, Andy