cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

script to monitor a service in linux

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

0 Kudos
1 Reply
Level 8

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.

0 Kudos