LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   get the pid of a a specific instance of the same program (https://www.linuxquestions.org/questions/linux-newbie-8/get-the-pid-of-a-a-specific-instance-of-the-same-program-626998/)

helsing 03-10-2008 11:32 AM

get the pid of a a specific instance of the same program
 
hello,

i am using wget to capture mp3 streams. how can i get the pid of the wget i just called so i can record that pid in a db or file and eventually kill that wget from another script. if i have several processes running/streams recording calling pidof wget will return the pids of all the wgets and not a specific one.

or can i get the pid of a wget by using the parameters that initially called the wget so i don't have to pass ids between scripts.

i hope this makes sense


steve

unSpawn 03-10-2008 12:01 PM

"$!" will hold the PID of the process previously executed, else 'pgrep' allows selection with globbing using "-f", so 'pgrep -d ' ' -f 'wget.*.*010101.mp3' should get all instances of the wget command where also one of the arguments also has "010101.mp3".

helsing 03-10-2008 12:10 PM

wicked, thanks!


All times are GMT -5. The time now is 04:08 PM.