[kwlug-disc] Parent Processes

John Van Ostrand john at netdirect.ca
Tue Jan 25 12:21:04 EST 2011


A simple answer is to check /proc/<pid> for the parent pid and recurse. 
Eventually it will be 1 and that's the top process.




  _____

From: kwlug-disc-bounces at kwlug.org
To: KWLUG discussion
Sent: Tue Jan 25 12:13:33 2011
Subject: [kwlug-disc] Parent Processes


Greetings,

I've been wrestling to find the parent process of perl scripts that are left 
running after exiting from the parent shell.  Specifically it is a search 
script that is started like this:

nohup search.pl -o output.txt -p <pattern> &

Following this, I exit the shell.  From another shell, running pstree, I can 
see:

search.pl, 12345 ....
    |--search.pl, 12346 ....
    |--search.pl, 12347

...up to about 20 times, which is how the script runs.

But if more than one search is running, I of course see this twice, with 
different pids.

search.pl, 12345 ....
    |--search.pl, 12346 ....
    |--search.pl, 12347....

search.pl, 3454 ....
    |--search.pl, 3455 ....
    |--search.pl, 3456....


What I'd like to find, with a bash script, is the parent process to these. 
It's easy to type in pstree, but I'd like the pid as a variable, but I'm 
having a hard time figuring out a shell command that will help me find 
these...


Any ideas out there?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20110125/b20a0fe8/attachment.htm>


More information about the kwlug-disc mailing list