By Aviel.shani
i wrote an simple script, that will monitor some services ,and if particular service will found down ,the code will restarts the service and message about the process will be sent on mail.
I have a problem somewhere in the syntax that the script initializes the service even if is up ..
Your help please, what should I fix the code :
#!/bin/bash
# Simple script that uses systemctl to check if a service is
# running. If its not it is restarted and an email is sent to
# the configured mailbox.
SERVICE=/etc/init.d/xinetd
MAILBOX=*********
STATUS=”/etc/init.d/xinetd status”
if [ “$SERVICE status” != ‘xinetd is stopped’ ]
then
/etc/init.d/xinetd restart
$STATUS | mail -s “the xinet.d service getting restart” $MAILBOX
fi
exit 0