Feeds:
Posts
Comments

Posts Tagged ‘solaris’

Today i came across a problem in solaris. The problem was that while starting my application server, it was throwing an error “Address already in use”.

My app server is a java process and there are many other java process which are running on my zone. But the issue is, how may i know that which java process is using that particular port?

I followed following steps:
1. List all the java process running on my zone ( ps -eaf |grep vagrawal| grep java )
2. Go through each java process and check if it using that particular port ( pfiles $pid|grep 1182 )
(here $pid is the process id of the java process and 1182 is the port number of which i am looking for)

Above method works fine but it is bit a long process, as i have to run step 2 for all java processes, so i ran a folowing command on my console:

for pid in `ps -eaf|grep vagrawal|grep java|grep -v grep|awk -F” ” ‘{print $2}’`; do echo ================= $pid >>myfile; pfiles $pid|grep 1182 >>myfile; done

above loop goes through all the java process and write there process IDs in the file ‘myfile’, and i am also checking usage of my port for that particular process (using pfiles) and prints its output in same file.

Finally there would be a single process which would be using that particular port. Now I can find easily that process in ‘myfile’

Now i have process ID of the process which is occupying my port, and i can kill that by kill -9 pid

Read Full Post »