Check Cyberpanel service 

 
">

Bangla programming tutorials

Cyberpanel auto restart

cyberpanel

Cyberpanel auto restart

 
 Add the content below to a bash script and run both commands under "Check each 5 minutes" (change /your/file.sh to the location and name of your file).

#!/bin/bash

# Check each 5 minutes
# echo "*/5 * * * * bash /your/file.sh" >> /var/spool/cron/root
# chmod +x /your/file.sh


# Array with: OLS PHP MariaDB PureFTP Postfix Dovecot Crontab
declare -a arr=("lsws" "lscpd" "mariadb" "pure-ftpd" "postfix.service" "dovecot" "crond.service")

# Loop through the above array
for i in "${arr[@]}"
do
status=$(systemctl status $i | grep Active: | cut -f2 -d"(" | cut -f1 -d")" | tr -d $'\n')
if [ "$status" != 'running' ]; then
systemctl restart $i
if [ "$i" = 'postfix.service' ]; then # Clear Postfix Mail Queue
postsuper -d ALL
postsuper -d ALL deferred
fi
fi
done

# You are all set!

Share This Post to Keep This Site Alive

Like FanPage: Like Post:

Comments

No comments to display for this post.

Leave A Feedback


Captch(Enter the number on the below field): 663