Linux - Find the pid of a running script, Return PID using ps and awk
Find the pid of a running script
Today when I was running my firefox, I ran into an issue and I thought to find the PID of the firefox and the command it was using. I'm sure it's totally overkill and there is a much easier way I didn't find to do this, but after some scouring of The Google, I found something that works!# ps -ef | grep firefox malu 2311 1 1 18:44 ? 00:00:14 /usr/lib/firefox-3.6/firefox malu 2671 2570 0 18:59 pts/0 00:00:00 grep --color=auto firefoxA little bit more data than I wanted, So by adding other commands I found the result.
# ps -eo pid,command | grep "firefox" 2311 /usr/lib/firefox-3.6/firefox 2909 grep --color=auto firefox
Remove the unwanted line
# ps -eo pid,command | grep "firefox" | grep -v 'grep' 2311 /usr/lib/firefox-3.6/firefox
Find only yhe PID of the script.
# ps -eo pid,command | grep "firefox" | grep -v grep | awk '{print $1}' 2311
The topic on Linux - Find the pid of a running script is posted by - Math
Hope you have enjoyed, Linux - Find the pid of a running scriptThanks for your time