LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   obtaining PID of shell script (https://www.linuxquestions.org/questions/programming-9/obtaining-pid-of-shell-script-204921/)

sanjith11 07-14-2004 11:33 AM

obtaining PID of shell script
 
hello,

How can i obtain the PID of a just started shell script.

Regards
SaN

Donboy 07-14-2004 11:38 AM

You can do ps -ef and look for the name of the program that's running. The PID will be shown in the second column, if memory serves.

See also:
http://www.linuxbase.org/spec/refspe...LSB/pidof.html

Dark_Helmet 07-14-2004 11:41 AM

You can also have the script itself report the value. The shell variable $$ contains the pid. If you need to share that information with external programs/scripts, just output it to a file. Something like:
Code:

echo $$ > /tmp/script_name.pid

itsme86 07-14-2004 11:43 AM

From inside the script you can use $$ to obtain the PID (e.g. echo $$)

EDIT: AHH! DH beat me to it :)


All times are GMT -5. The time now is 05:57 AM.