• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

mail service stops over and over

W

wasim676

Guest
Hi,

Plesk mail service stops daily in the morning. We are to restart mail service over and over. How this problem permanently can be resolved.

Please! Help in this regard. Thanks in Advance.

Best Regards,

Wasim.
 
Not sure how to fix it, but here's a little script i have to that will monitor your services for you. You just add the services you want into the script and it will automatically check to see if they are running. If they aren't it will attempt to restart them. If it cannot, it will e-mail you an alert. You should run in this in a 15 minute cron or something.

#!/bin/bash
SERVER=$(hostname)

# E-mail address you want to send restart failures to
EMAIL="[email protected]"

# Directory where script is located (no trailing slash)
SCRIPT_PATH="/path/to/script/dir"

# Log file that you want to capture events in
STATUS_LOG="$SCRIPT_PATH/status.log"

# Services you want to monitor
SERVICES="httpd mysqld postgresql qmail psa"

echo "Service Report for $SERVER" > $STATUS_LOG
echo "===========================================" 1>> $STATUS_LOG
echo "Run on $(date)" 1>> $STATUS_LOG
echo "===========================================" 1>> $STATUS_LOG

for i in $SERVICES; do

# Check the status of the services in the list
STATUS=$(/sbin/service $i status | sed -re 's/(pid|\(|\)|[0-9]{2,}|\.\.\.|\ )//g;s/\is/ : /g')
echo "[*] $STATUS" 1>> $STATUS_LOG

# If the string "running" could not be found, the service is assumed stopped
if [[ ! $STATUS == *running ]]; then
echo " - $i found to be not running. Restarting $i..." 1>> $STATUS_LOG

# Attempt to start the service
/sbin/service $i restart

# Make sure that the service was actually re-started.
NEW_STATUS=$(/sbin/service $i status | sed -re 's/(pid|\(|\)|[0-9]{2,}|\.\.\.|\ )//g;s/\is/ : /g')

if [[ ! $NEW_STATUS == *running ]]; then
echo " [x] $i could not be restarted. Please contact Support." 1>> $STATUS_LOG
else
echo " [*] $i has been restarted successfully." 1>> $STATUS_LOG
fi

cat $STATUS_LOG | mail -s "Service Monitor ($SERVER): $i FAILED" $EMAIL
fi

done

exit 0
 
Back
Top