程序被异常关闭,我再次运行时,显示 address is already in use
解决办法:
查看端口
##lsof -i tcp:端口 and netstat -tlnp|grep 端口
root@star-SYS-7048GR-TR:/home/star# lsof -i tcp:8558
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python3.6 10875 star 23u IPv4 46890182 0t0 TCP *:8558 (LISTEN)
root@star-SYS-7048GR-TR:/home/star# netstat -tlnp|grep 8558
tcp 0 0 0.0.0.0:8558 0.0.0.0:* LISTEN 10875/python3.6
杀死进程
root@star-SYS-7048GR-TR:/home/star# kill -9 10875
查看python进程
pstree |grep python
or
ps -ef |grep python
有时,我们在命令行下需要直接终止python程序,这时我们可以使用Ctrl+z,然后我们调用上面的查看进程代码,发现执行当前脚本的进程并没有消失。这时我们就可以使用上面的命令查看进程的id。
然后执行