From 2444ac46a0f0c41560558cb194a98e093a8466e3 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 22 Jul 2024 16:39:52 -0400 Subject: [PATCH] helper to kill a service on a specific port --- nix/base-system/.zshrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nix/base-system/.zshrc b/nix/base-system/.zshrc index ffcaf44..4de4e2b 100644 --- a/nix/base-system/.zshrc +++ b/nix/base-system/.zshrc @@ -26,3 +26,12 @@ function wrkspc() { local session=$(basename $wd) tmux new -A -s $session } + +function kill_service_on_port() { + local port=$1 + echo killings pids for port ${port} + for p in $(sudo lsof -nP -iTCP -sTCP:LISTEN | grep ${port} | awk '{ print $2 }'); do + echo killing pid: $p; + kill -9 $p; + done +}