July 18, 2012

Find pid in Solaris 10


If you do not know the pid of a process, you can use "pidof" command in Linux. In case of Solaris, its not available.

Here's how you can find it:

 #ps -ef | grep nscd | grep -v grep | cut -c12-19
123

Here, it will find the pid of nscd. the cut command will cut characters from 12 to 19 from output of 'ps -ef' command.
or
 #ps -ef | grep nscd | grep -v grep | awk '{print $2}'
Here, we use awk to print second column of ps.

Labels: , , ,

2 Comments:

At October 29, 2013 at 12:47 PM , Anonymous Anonymous said...

Not working, will also output PIDs of any commandline call containing (in this case) "nscd", e.g. as a parameter or part of the full command.

 
At February 23, 2017 at 10:41 PM , Blogger YvesGuerin said...

Dear,

I found my way: change /etc/init.d/mysql in Solaris-10

echo `pgrep mysqld | tr '\n' ' '` > /tmp/mysqld.pid
mysqld_pid=`cat /tmp/mysqld.pid`
#mysqld_pid=`pidof $libexecdir/mysqld`
rm -rf /tmp/mysqld.pid > /dev/null 2>&1

Regards

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home