script to monitor a service in linux

Can you please share me the script i can use it a Linux

  • Monitor for what? That it exists / is running?

    Which version of Linux?

    The following will check if 'apache2' is running on debian(s).


    #! /bin/bash

    if [ $(ps aux | grep apache2 | wc -l) -gt 1 ]; then

    echo "Statistic:0"


    echo "Statistic:1"


    exit 0;


    Change 'apache2' to your service and see if it works for you.