Check service state minutely and take it to the expected state bash

1- /etc/cron.d/control
MAILTO=root
* * * * * root [ -x /usr/local/sbin/check_service.sh ] && /usr/local/sbin/check_service.sh
2- /usr/local/sbin/check_service.sh
#!/bin/sh
CMD=/etc/init.d/servicename
[ -x $CMD ] || exit 0
STATUS=$($CMD status)
[ $? != 0 ] && $CMD start 2>&1 > /dev/null
exit 0
3- chmod 700 /usr/local/sbin/check_service.sh
4- /etc/init.d/crond restart
kaynak: nuhazginoglu.com

Yorumlar