Archive for the ‘AutoRestart Production Service’ Category


Example 1:

#!/bin/bash
ser=vsftpd
PS=`ps -ef | grep -v grep | grep vsftpd | wc -l`
if [ $PS -gt 0 ]
then
echo “$ser is running”
else
echo “$ser service is not running”
service $ser restart
fi

Example 2

#!/bin/bash
SERVICE=vsftpd

#if ps ax | grep -v grep | grep $SERVICE
if service vsftpd status
then
echo “$SERVICE service running, everything is fine”
else
echo “$SERVICE is not running”
/sbin/service $SERVICE restart
/sbin/chkconfig $SERVICE on

fi

[root@ldap1 ~]# crontab -l
*       *       *       *       *       /bin/sh /root/test1.sh

Advertisements