auto-restart chkservd

chkservd is a service that monitors some services and (re)start them in case they stop

the problem is that sometimes chkservd may stop working auto-restart chkservd

so here is a little script to check if it's running and start otherwise:

Code:
#!/bin/sh

if [ "`service chkservd status | awk '{print $5}'`" != "running..." ]; then
  echo "Restarting chkservd... "
  service chkservd restart

  echo "chkservd was restarted at `date` on `hostname`" | mail -s "chkservd restarted" root
fi
1) save as /usr/local/bin/chkchkservd.sh (or whatelse you want)
2) edit /usr/local/bin/chkchkservd.sh and change the last word of line 7... it's "root" so it means an E-Mail will be sent to root when it restart... you can put something like "yourname@yourisp.com"
or you can comment this line with a # in the start if you don't want to receive E-Mails (i don't recomment doing that)...
3) chmod 700 /usr/local/bin/chkchkservd.sh
4) crontab -e
5) add */10 * * * * /usr/local/bin/chkchkservd.sh >/dev/null 2>&1

also, i suggest that SIM add some code to monitor chkservd like this one auto-restart chkservd

(i know SIM and chkservd has almost the same function, but i like using both because chkservd checks for cppop too)

 

 

 

 

Top