Created
November 26, 2013 11:59
-
-
Save robertoaloi/7657243 to your computer and use it in GitHub Desktop.
Kill an Erlang process by node name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Kill an Erlang process by node name | |
# | |
# e.g.: ekill my_node | |
# Check usage | |
if [ -z "$1" ]; then | |
echo "Usage: `basename $0` NODE_NAME" | |
exit 1 | |
fi | |
# Fetch input parameters | |
name="$1" | |
# Kill the Erlang process corresponding to a given node name | |
port=`epmd -names | awk -v name=$name '$2==name {print $5}'` | |
if [ -z "$port" ]; then | |
echo "ERROR: Node name not found: $1" | |
exit 1 | |
else | |
pid=`lsof -i TCP:$port -s TCP:LISTEN | tail -n +2 | awk '{print $2}'` | |
kill $pid | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment