Clamav-daemon service down

Hello,
I have many VPS some have 2gb memory and face clam av down, so I use this script every 5 min

#!/bin/bash
#Wael https://www.wael.name
serv=clamd
servname=clamav-daemon
sstat=$(pidof $serv | wc -l )
if [ $sstat -gt 0 ]
then
echo “$servname is running fine!!!”
else
echo “$servname is down/dead”
service $servname start
echo “$servname service is UP now!!!” | mail -s “$servname service is DOWN and restarted now On $(hostname)” [email protected]
fi

I hope to help someone

where you add that script ?

You can save the file in root folder and add cron job hourly
use etc cron not Hestiap cron

Just create the script
nano /home/michael/clamd-watchdog.sh
chmod +x /home/michael/clamd-watchdog.sh
Add it to cron
crontab -e or via panel

Hestia overwrites crontab file on rebuild so via panel is saver…

1 Like

Good to know.

I use /etc/crontab in all server and any control panel I use

Thank you for your answer …

I get mail error

clamav-daemon is down/dead”
clamd-watchdog.sh: line 11: service: command not found
clamd-watchdog.sh: line 12: mail: command not found

Do you install Clamav ?

Only in servers with email since it doesn’t scan for php scripts.