This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

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"

    else

    echo "Statistic:1"

    fi

    exit 0;

    }

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