Find Which Process Binded to my Port:
There are lot of instances whereWe will come across a situation where we need to chase to find the process
for a give port , if there are 20-30 of java process running on box.
Developers are no clue whatz going , what process they are killing what process they are starting etc etc
Here is a sample script which will take port as input and give us the process id
#!/bin/bash if [ $# -lt 1 ] then echo "Usage: getpid.sh |port| " echo "Please retry with correct options" echo "if you want to suppress the output with unnecessary string like 'permission denied'" echo "Use: ./getpid.sh |port| > 2>/dev/null " exit fi echo "Scanning for your port............!!!!!!!!!!!!!!" ls /proc | while read i do pfiles $i | grep AF_INET | grep $1 |grep peername if [ $? -eq 0 ] then echo Is owned by pid $i echo fi done echo "Script Completed Successfully..." echo
./getSolarisPid.sh 12082
./getSolarisPid.sh 12082 2>/dev/null (if you want to supress the permission denied messgs')
LINUX
netstat -tulanp |grep <pid>
Find the process id and grep using ps
ps -ef |grep 11817