Files
weiyu/modules/python/stop.sh
2024-12-14 10:43:31 +08:00

18 lines
489 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
###
# 添加权限 chmod +x stop.sh
# 查找监听在9007端口的进程ID (PID)
# 使用netstat命令可能需要sudo权限
# PID=$(netstat -tulnp | grep ':9007 ' | awk '{print $7}' | cut -d'/' -f1)
# 或者使用lsof命令可能需要sudo权限
PID=$(lsof -t -i:9007)
if [ -z "$PID" ]; then
echo "No process found listening on port 9007."
else
# 终止找到的进程
kill $PID
echo "Process with PID $PID listening on port 9007 has been terminated."
fi