shell/ target=_blank class=infotextkey>shell脚本检测端口占用:
复制代码 代码示例:
#!/bin/bash
#
port=$1
echo "check $port"
grep_port=`netstat -tlpn | grep "b$portb"`
echo "grep port is $grep_port"
if [ -n "$grep_port" ]
then
echo "port $port is in use"
exit 1
else
echo "port is not in use"
fi