From owner-freebsd-questions Sun Nov 10 7:37:39 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B8B9C37B401 for ; Sun, 10 Nov 2002 07:37:38 -0800 (PST) Received: from Kain.sumuk.de (Kain.sumuk.de [213.221.86.114]) by mx1.FreeBSD.org (Postfix) with ESMTP id 61BCA43E42 for ; Sun, 10 Nov 2002 07:37:37 -0800 (PST) (envelope-from vincent@sumuk.de) Received: from Moses.earth.sol (Moses.earth.sol [192.168.1.1]) by Kain.sumuk.de (8.12.5/8.12.5) with ESMTP id gAAFbTpF077715; Sun, 10 Nov 2002 16:37:29 +0100 (CET) (envelope-from vincent@sumuk.de) Received: from Moses.earth.sol (localhost.earth.sol [127.0.0.1]) by Moses.earth.sol (8.12.5/8.12.5) with ESMTP id gAAFbRLS014645; Sun, 10 Nov 2002 16:37:28 +0100 (CET) (envelope-from vincent@Moses.earth.sol) Received: (from vincent@localhost) by Moses.earth.sol (8.12.5/8.12.5/Submit) id gAAFbRpd014644; Sun, 10 Nov 2002 16:37:27 +0100 (CET) Date: Sun, 10 Nov 2002 16:37:26 +0100 From: Martin Heinen To: Neil Doody Cc: freebsd-questions@FreeBSD.ORG Subject: Re: make pid files Message-ID: <20021110163726.B14403@sumuk.de> References: <000001c288c9$56c091a0$0200a8c0@b1> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <000001c288c9$56c091a0$0200a8c0@b1>; from neil@mpfreescene.com on Sun, Nov 10, 2002 at 02:56:13PM -0000 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Nov 10, 2002 at 02:56:13PM -0000, Neil Doody wrote: > Is there a way to create pid files for applications you start, if the > application doesn't have a configuration option within itself to create > one ? > > Im guessing using some kind of regex with grep to capture the pid/error > number when you run it ? If you are running background commands you can use $!: | #!/bin/sh | job & | echo "$!" > /var/run/job.pid If the job puts itself into the background you need to grep the PID: | #!/bin/sh | job | ps auxw | awk '/[j]ob/ { print $2 }' > /var/run/job.pid Be sure to supply a pattern which matches one process only. -- Marxpitn To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message