LoginSignup
0
0

More than 1 year has passed since last update.

プロセスがあるか調べる

Posted at

すっかり ansible でやるようになったものの、必要になったときにすぐ出て来ないと困ったりするやつ

chk_proc(){
    if pgrep "$1" > /dev/null ; then
        printf "\033[32m%s\033[m\n" "running: ${1}"
    else
        printf "\033[31m%s\033[m\n" "stopped: ${1}"
    fi
}

systemctl の場合

chk_svc(){
    if [ $(systemctl is-active "$1") == "active" ] ; then
       printf "\033[32m%s\033[m\n" "running: ${1}"
    else
       printf "\033[31m%s\033[m\n" "stopped: ${1}"
    fi
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0