THE SPEW - Land where drunk cows swim and home to my daily hand...
streaming media & music | Home | Archives | Albums | Pics

bash script to check and report the status of selected processes

07 November, 2007 02:35

This is a version of a cron executed bash script I wrote to check and report the status of selected processes, and then send an e-mail of the results:

#!/bin/sh

cmdtest='smtpd gdm cupsd any-process-name'

echo "checking status of critical services... $cmdtest"

echo " "

for name in $cmdtest ; do
statq=$(/bin/ps -C $name |/bin/grep -n 0)
if [ -z "$statq" ]
then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "$name not running!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
else
echo "$(/bin/ps -C $name)"
fi ; done

echo " "
exit 0
 

[Software]
[Comments(0)] [Trackbacks(0)] [Permalink]

Add comment

Add comment
 authimage
Your E-Mail Address will NOT be Shared

Main Entry: spew
Function: verb
Etymology: Middle English, from Old English spIwan; akin to Old High German spIwan to spit, Latin spuere, Greek ptyein intransitive verb
1 : VOMIT
2 : to come forth in a flood or gush
3 : to ooze out as if under pressure : EXUDE transitive verb
1 : VOMIT
2 : to send or cast forth with vigor or violence or in great quantity -- often used with out - spew-er noun
--
Merriam-Webster

Land where drunk cows swim and home to my daily hand