DISQUS

DISQUS Hello! Tech-Recipes is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Tech-Recipes

Cookbook of Tech Tutorials
Jump to original thread »
Author

Find out which process is holding which socket open | UNIX | Tech-Recipes

Started by qdideas · 9 months ago

No excerpt available. Jump to website »

3 comments

  • Actually, you can skip a whole step there... if you add the '-p' argument to netstat, it includes the PID of the process in question!

    So instead of netstat -an, try netstat -anp.
  • netstat -anp works on linux, but not Solaris :-(
  • Just use /usr/proc/bin/pfiles <pid> bit of a pain to do it in reverse (i.e. speicfy pid to get the port) but a simple script can rip thru it for you....

    echo "which port?> "
    read port

    for pid in `ps -ef -o pid | tail +2`
    do
    foundport=`/usr/proc/bin/pfiles $pid 2>&1 | grep "sockname:" | grep "por
    t: $port$"`
    if [ "$foundport" != "" ]
    then
    echo "proc: $pid, $foundport"
    fi
    done

Add New Comment

Returning? Login