Skip to content

Instantly share code, notes, and snippets.

@amoilanen
Created October 14, 2023 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amoilanen/d4815716b0b96c81d131c08f50b7d9b4 to your computer and use it in GitHub Desktop.
Save amoilanen/d4815716b0b96c81d131c08f50b7d9b4 to your computer and use it in GitHub Desktop.
.bashrc utilities to free a port and terminate a process
#!/bin/bash
free_port() {
kill -9 $(lsof -t -i:$1)
}
terminate() {
pids_to_kill=$(ps aux|grep $1|grep -v grep|grep -v terminate.sh |awk '{print $2}')
[[ ! -z $pids_to_kill ]] && kill -9 $pids_to_kill
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment