Capturing a PID.
Don Harrop
plug-discuss@lists.PLUG.phoenix.az.us
Fri, 25 May 101 14:26:40 EST
Thanks Tom, My original finding of jobs -l doesn't work because there is not associated tty. The command "jobs" just prints null. I think your $! will work though.. Thanks!
---------- Original Message ----------------------------------
From: Tom Bradford <bradford@dbxmlgroup.com>
Reply-To: plug-discuss@lists.PLUG.phoenix.az.us
Date: Fri, 25 May 2001 11:02:11 -0700
>Don Harrop wrote:
> Does anyone have ideas on how to capture the pid of a program into a file as it starts up? When you execute your program with the "&" (background process) the shell spits out the process id but I can't seem to redirect that out put to a file. I don't want to use "pidof" after the fact either in case there is another process running with the same name.
Try this:
<your command> &
echo $! > program.pid
$! is the most recent program executed.
$$ is the current shell script
I've attached a copy of dbXML's startup script and its SYSV wrapper for
a better example.
--Tom
--
Tom Bradford --- The dbXML Project --- http://www.dbxml.org/
We store your XML data a hell of a lot better than /dev/null