脚本刚写好,中午就不开虚拟机测试了,晚上到家一道测试
01
#!/bin/bash
02
#检查8080端口是否被占用,如果占用输出1,如果没有被占用输入0
03
pIDa=`/usr/sbin/
lsof
-i :8081|
grep
-
v
"PID"
|
awk
'{print $2}'
`
04
echo
$pIDa
05
if
[
"$pIDa"
!=
""
];
06
then
07
"1"
08
else
09
"0"
10
fi