add to your bash_profile, or bashrc file etc.
port_kill() { if [ -z "$1" ]; then echo "Usage: port_kill PORT_NUMBER" return 1 fi PIDs=$(lsof -t -i :"$1" 2>/dev/null) if [ -n "$PIDs" ]; then kill -9 $PIDs 2>/dev/null echo "✓ Successfully killed process(es) running on port $1" return 0 else echo "No process running on port $1" return 1 fi } alias force-kill='port_kill' usage
force-kill 3000
Top comments (0)