how to find PID of a runnign process ?

Hi Friends,

How can we find the process ID of a running process using the process name. In AIX I used to use the command "ps -ef | grep <process name>", it used to give me the owner of that process, Process ID and the threads running and the name of the process in the end.

However in Solaris it will not give me the following output:

ssarda@:/ind/home/ssarda>ps -ef | grep autocard_server
ssarda 12834 3443 0 17:11:58 pts/34 0:00 grep autocard_server

However If I got to the location where the <process_name>.pid file is created and read it, it gives me a different PID. I am new to solaris.

How can we find the exact process ID of the process using the name of the process. Is there any script that we can use to find the PID of the process ?

Please help !!

You'll want to include the header record from the ps output to get your bearings:

ps -ef |egrep "PID|autocard_server" 

Alternatively, you can go with the UCB version of ps to capture the entire command-line associated with the process:

/usr/ucb/ps augxww |egrep "PID|autocard_server" 

Try:

pgrep -fl autocard_server
1 Like