Shell script to check process is running or not in Linux

Write a Shell script to check process is running or not in Linux

#!/bin/bash
pid=`pgrep -f apache2`
pid_count=${#pid[@]}

if [  $pid_count -gt "1" ];then
      echo "Apache pid not found"
      exit 1
else
    echo "Starting service"
     service apache2 start
fi
Share on Google Plus

About Penguin Technology

I am a passionate cloud and DevOps professional specializing in Linux and open-source solutions. Through this blog, I share my knowledge and experience with the community, offering tips and insights on cloud technologies and DevOps practices.
    Blogger Comment

0 comments:

Post a Comment