Linux解决tomcat80端口被占用

停止tomcat进程shutdown.sh,停止tomcat后telnet127.0.0.180,发现80端口依然可用。netstat-an|grep80查看发现有许多80端口进程在里面,使用killpid命令终止进程,无用。使用lsof-i:80|grep-v"PID"|awk'{print"kill-9",$2}'命令后所有80端口进程删除。重新启动tomcat,系统正常运行。不过为什么tomcat在关闭时却不能将80端口的进程一并关闭的原因需要分析一下。

[root@gzcourtbin]#netstat-an|grep80

tcp00::ffff:127.0.0.1:8005:::*LIST

EN

tcp00:::8009:::*LIST

EN

tcp00:::80:::*LIST

EN

tcp00:::8080:::*LIST

EN

tcp00::ffff:172.16.1.153:80::ffff:202.160.179.12:36057TIME

_WAIT

tcp00::ffff:172.16.1.153:80::ffff:202.160.178.15:39176TIME

_WAIT

tcp00::ffff:172.16.1.153:80::ffff:218.20.57.173:55001ESTA

BLISHED

tcp00::ffff:172.16.1.153:80::ffff:218.20.57.173:3516ESTA

BLISHED

tcp00::ffff:172.16.1.153:80::ffff:218.20.57.173:55037ESTA

BLISHED

tcp00::ffff:172.16.1.153:80::ffff:218.20.57.173:3518ESTA

BLISHED

tcp00::ffff:172.16.1.153:80::ffff:61.135.162.208:57893TIME

_WAIT

tcp00::ffff:172.16.1.153:80::ffff:210.72.4.122:39196ESTA

BLISHED

tcp00::ffff:172.16.1.153:80::ffff:59.32.124.136:22529ESTA

BLISHED

tcp00::ffff:172.16.1.153:80::ffff:218.20.57.173:55222ESTA

BLISHED

tcp00::ffff:172.16.1.153:80::ffff:218.20.57.173:3510ESTA

BLISHED

tcp00::ffff:172.16.1.153:80::ffff:59.32.124.136:22530ESTA

BLISHED

tcp00::ffff:172.16.1.153:80::ffff:210.72.4.122:39198ESTA

BLISHED

unix3[]STREAMCONNECTED6880/tmp/.X11-unix/X0

#lsof-i:80|grep-v"PID"|awk'{print"kill-9",$2}'|sh

以上脚本可以清除80端口的进程

相关推荐