The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > HP-UX
Google UNIX.COM


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help in background process chella Shell Programming and Scripting 5 12-03-2007 10:57 PM
background process vinod.thayil Shell Programming and Scripting 1 08-17-2007 02:56 AM
background process k_oops9 Shell Programming and Scripting 3 11-15-2004 12:15 AM
background process badshah High Level Programming 3 05-30-2003 08:01 AM
capture the process id when starting a background process jleavitt Shell Programming and Scripting 10 04-04-2002 05:04 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-09-2005
Registered User
 

Join Date: Feb 2005
Posts: 2
Stumble this Post!
PIDs of background process

How to track the pid of a background child process(shell script) from a parent script ?

For example :-

$ sleep 10000 &
[1] 4220

where 4220 is the pid of bg process sleep.

Now my requirement is to keep the sleep statement in a shell script(test.ksh) and will be invoking it from another shell script (test2.ksh).

Is there any way to get the pid of test.ksh (child background process) from test2.ksh?

Last edited by ramkumar; 02-09-2005 at 02:44 AM. Reason: To make it more clear
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-09-2005
Registered User
 

Join Date: Feb 2005
Posts: 34
Stumble this Post!
ram...
when u r creating the script test2.ksh, immeditaely after you call test.ksh you could give ID=$$
ID being just another variable, $$ would give the PID of the last process you have run.


Quote:
Originally Posted by ramkumar
How to track the pid of a background child process(shell script) from a parent script ?

For example :-

$ sleep 10000 &
[1] 4220

where 4220 is the pid of bg process sleep.

Now my requirement is to keep the sleep statement in a shell script(test.ksh) and will be invoking it from another shell script (test2.ksh).

Is there any way to get the pid of test.ksh (child background process) from test2.ksh?

Last edited by Naanu; 02-09-2005 at 07:58 AM.
Reply With Quote
  #3 (permalink)  
Old 02-09-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,812
Stumble this Post!
$! is the pid of the most recent process, $$ is the pid of the current process, $PPID is the parent pid. In Korn shell.
Reply With Quote
  #4 (permalink)  
Old 02-09-2005
Registered User
 

Join Date: Feb 2005
Posts: 34
Stumble this Post!
whooopsie jim...thx for correcting...

Quote:
Originally Posted by jim mcnamara
$! is the pid of the most recent process, $$ is the pid of the current process, $PPID is the parent pid. In Korn shell.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0