PIDs of background process | Unix Linux Forums | HP-UX

  Go Back    


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

PIDs of background process

HP-UX


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-09-2005
ramkumar ramkumar is offline
Registered User
 
Join Date: Feb 2005
Last Activity: 19 August 2006, 2:34 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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 05:44 AM.. Reason: To make it more clear
Sponsored Links
    #2  
Old 02-09-2005
Naanu Naanu is offline
Registered User
 
Join Date: Feb 2005
Last Activity: 5 November 2007, 9:04 PM EST
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
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 10:58 AM..
Sponsored Links
    #3  
Old 02-09-2005
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 2 September 2014, 2:56 PM EDT
Location: NM
Posts: 10,181
Thanks: 275
Thanked 785 Times in 734 Posts
$! is the pid of the most recent process, $$ is the pid of the current process, $PPID is the parent pid. In Korn shell.
    #4  
Old 02-09-2005
Naanu Naanu is offline
Registered User
 
Join Date: Feb 2005
Last Activity: 5 November 2007, 9:04 PM EST
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Capturing PIDs of same process at different instances suryaemlinux Shell Programming and Scripting 3 11-02-2011 11:12 AM
How to put FTP process as a background process/job in perl? vanitham Shell Programming and Scripting 5 07-18-2011 11:54 PM
Script to start background process and then kill process holocene UNIX for Dummies Questions & Answers 4 06-10-2010 03:39 AM
How to run background(child) process in PHP without blocking the usual flow of parent process on Lin elizas Linux 1 02-03-2010 05:13 PM
capture the process id when starting a background process jleavitt Shell Programming and Scripting 10 04-04-2002 07:04 AM



All times are GMT -4. The time now is 02:58 PM.