Issue
I'm using if lsof -Pi :8080 -sTCP:LISTEN -t >/dev/null ;
and it worked fine on RHEL6 (4.82). But on RHEL5 (4.78) I'm seeing an error:
lsof: unsupported TCP/TPI info selection: C lsof: unsupported TCP/TPI info selection: P lsof: unsupported TCP/TPI info selection: : lsof: unsupported TCP/TPI info selection: L lsof: unsupported TCP/TPI info selection: I lsof: unsupported TCP/TPI info selection: S lsof: unsupported TCP/TPI info selection: T lsof: unsupported TCP/TPI info selection: E lsof: unsupported TCP/TPI info selection: N lsof 4.78.
Can someone suggest an alternative to the above command?
I'm using this command to check the application status of servers with my assigned port numbers.
Solution
This gives you the PID and the port status.
netstat -pln | grep 9080
if you have multiple ports to check for, you could use this
for portnum in 9080 8080 8088 9082
do
if [ $(netstat -pln 2>/dev/null | grep -c ${portnum}.*LISTEN) -eq 1 ]
then
echo "Port ${portnum} is up"
else
echo "Port ${portnum} is down"
fi
done
you can ignore the "2>/dev/null" if you are running the command under root.
Answered By - SudoAgent