Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Nov 2002 16:37:26 +0100
From:      Martin Heinen <martin@sumuk.de>
To:        Neil Doody <neil@mpfreescene.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: make pid files
Message-ID:  <20021110163726.B14403@sumuk.de>
In-Reply-To: <000001c288c9$56c091a0$0200a8c0@b1>; from neil@mpfreescene.com on Sun, Nov 10, 2002 at 02:56:13PM -0000
References:  <000001c288c9$56c091a0$0200a8c0@b1>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021110163726.B14403>