Last active
April 20, 2018 13:50
-
-
Save Jeetah/a6b1e454f07c691f529b632d1a3b0563 to your computer and use it in GitHub Desktop.
Kill process by name shell script
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/bash | |
set -euo pipefail | |
PROCESS_NAME=$1 | |
PID_PRC=`ps aux | grep '${PROCESS_NAME}' | grep -v grep | awk '{print $2}'` | |
if [ -n "$PID_PRC" ] | |
then | |
echo "Found running process -> killing PID: '$PID_PRC'" | |
kill $PID_PRC | |
else | |
echo "Process not running" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment