Last active
October 6, 2015 15:01
-
-
Save toya33/64687c810657cff31f46 to your computer and use it in GitHub Desktop.
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
引数として渡されたプロセス名が起していれば | |
プロセスを強制終了する | |
process.sh | |
------------------------------ | |
#!/bin/sh | |
#プロセス名を引数として受け取る | |
PROCESS_NAME=$0 | |
#取得したプロセスを基にプロセスを検索 | |
COMMAND_RESULT=`ps aux | grep $PROCESS_NAME | grep -v grep` | |
#プロセスlが起動していればプロセスを強制終了 | |
echo "$COMMAND_RESULT" | grep "$PROCESS_NAME" >/dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
killall -9 $PROCESS_NAME | |
fi | |
exit 0 | |
------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment