how to get process id attached with particular port in solaris
When you need to know process id attached with particular port use below command.
pfiles /proc/* 2>/dev/null | nawk ' /^[0-9]*:/ { pid=$0 } /port: 7085$/ { printf("%s %s\n",pid,$0);}'
pfiles /proc/* 2>/dev/null | nawk ' /^[0-9]*:/ { pid=$0 } /port: 7085$/ { printf("%s %s\n",pid,$0);}'
- pfiles /proc/* is retrieving all processes file descriptors details
- 2>/dev/null is dropping out errors due to transient processes died in the meantime
- each line starting with a number followed by a colon reports the process id and details, it is stored in the awk pid variable
- when a line ends with the string port: <portnumber> (here is 7085), the corresponding pid variable is displayed.
Comments