As the title says, I\'m running multiple game servers, and every of them has the same name
but different PID
and the port
number. I would
Since sockstat wasn't natively installed on my machine I hacked up stanwise's answer to use netstat instead..
netstat -nlp | grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\:2000" | awk '{print $7}' | sed -e "s/\/.*//g""
The -p
flag of netstat
gives you PID of the process:
netstat -l -p
Edit: The command that is needed to get PIDs of socket users in FreeBSD is sockstat
.
As we worked out during the discussion with @Cyclone, the line that does the job is:
sockstat -4 -l | grep :80 | awk '{print $3}' | head -1