Difference between revisions of "Auto Check Script - Postfix Server"

(Created page with "Auto Check Script for Postfix Server.<br> <br> Run this shell script as a cron job every minute: <pre> #!/bin/bash #Auto check and reparation of postfix server - written by...")
 
(No difference)

Latest revision as of 17:20, 7 August 2019

Auto Check Script for Postfix Server.

Run this shell script as a cron job every minute:

#!/bin/bash

#Auto check and reparation of postfix server - written by [email protected]

_zustandsql=$( systemctl status postfix.service | grep -sw 'active')

if [ ! -z "_zustandsql" -a "$_zustandsql" != "" ]; then
#running
sleep 1

else
#NOT RUNNING
sleep 25
_zustandsql=$( systemctl status postfix.service | grep -sw 'active')
if [ ! -z "_zustandsql" -a "$_zustandsql" != "" ]; then
#running
sleep 1

else
#NOT RUNNING
echo $(date) > /var/log/autochecks/postfixserver.log
echo " - !!! CRASHED at the shown time and was auto repaired. Please check service if there are any Problems." >> /var/log/autochecks/postfixserver.log

sleep 6


service postfix restart

fi
fi


Pleae adjust this as you like.