2019-04-09

ps -ef grep -v multi


Google'ed by: ps -ef grep -v multi




Reference URL: https://stackoverflow.com/a/13330924/676104


Use a separated list of of processes:
#!/bin/bash
PROC="nginx mysql ..."
for p in $PROC
do
  ps cax | grep $p > /dev/null

  if [ $? -eq 0 ]; then
    echo "Process $p is running."
  else
    echo "Process $p is not running."
  fi

done
If you simply want to see if either one of them is running, then you don't need loo. Just give the list to grep:
ps cax | grep -E "Nginx|mysql|etc" > /dev/null



To exclude by using:


ps -ef | grep -vE "grep|vim |tail " | grep tomcat








No comments:

Google Referrals