diff --git a/bin/clear-port b/bin/clear-port new file mode 100755 index 0000000000..837079a880 --- /dev/null +++ b/bin/clear-port @@ -0,0 +1,15 @@ +#!/bin/sh + +# Kills the process running on the provided port +# +# clear-port 3000 + +if [ -n "$1" ]; then + port_num="$(lsof -ti4TCP:"$1")" + if [ $? -eq 0 ]; then + kill "$port_num" + fi +else + echo >&2 Usage: clear_port port-number + exit 1 +fi diff --git a/bin/whats-in-port b/bin/whats-in-port new file mode 100755 index 0000000000..476f77fd25 --- /dev/null +++ b/bin/whats-in-port @@ -0,0 +1,16 @@ +#!/bin/sh + +# List process running on provided port +# +# whats-in-port 3000 +# +# output: +# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME +# ruby 25583 root 11u IPv4 0xee20607697a79bf7 0t0 TCP *:irdmi (LISTEN) + +if [ -n "$1" ]; then + lsof -ni4TCP:"$1" +else + echo >&2 Usage: whats_in_port port-number + exit 1 +fi