Skip to content

Instantly share code, notes, and snippets.

@skatsuta
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save skatsuta/1de7c0c31824f95a14d4 to your computer and use it in GitHub Desktop.

Select an option

Save skatsuta/1de7c0c31824f95a14d4 to your computer and use it in GitHub Desktop.
プロセスの起動確認
#!/bin/bash
PROCESS=$1
PROCESS_NUM=$(ps cax | grep $PROCESS | wc -l)
# 引数チェック
if [ $# -eq 0 ]; then
echo "Usage: $0 process_name" 1>&2
exit1
fi
if [ $PROCESS_NUM -gt 0 ]; then
echo "$PROCESS running."
else
sudo service $PROCESS start
echo "$PROCESS started."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment