If you’re running WHM/cpanel and want to run a scan on every user manually, perhaps when first installing ClamAV, you’ll want to run this command which is endorsed by cPanel themselves.
To enable ClamAV, you’ll want to enter WHM –> Configure ClamAV Scanner and select the check boxes for the type of scan you want to do.
Once that’s done, you can run it with this command:
1 |
for i in `awk '!/nobody/{print $2 | "sort | uniq" }' /etc/userdomains | sort | uniq`; do /usr/bin/clamscan -i -r /home/$i 2>>/dev/null; done >> /root/infections& |
Once its running, you can tail the /root/infections log file to see what it finds. You’ll start to see scan results as it finishes each user’s home directory.
You can then set up a root cron job to have it run during off hours. The example below will fire it off at 2am every night.
(ssh into the server and become root)
1 |
crontab -e |
1 |
0 2 * * * for i in `awk '!/nobody/{print $2 | "sort | uniq" }' /etc/userdomains | sort | uniq`; do /usr/bin/clamscan -i -r /home/$i 2>>/dev/null; done >> /root/infections& |
NOTE: this will just tell you about the infections it finds. You have two options if you’d like to deal with them during the scan:
Remove them (careful, this will delete the file forever.. if it’s a false positive, then you’re SOL).
1 |
0 2 * * * for i in `awk '!/nobody/{print $2 | "sort | uniq" }' /etc/userdomains | sort | uniq`; do /usr/bin/clamscan -i -r /home/$i --remove 2>>/dev/null; done >> /root/infections& |
Move them to a different folder:
1 |
0 2 * * * for i in `awk '!/nobody/{print $2 | "sort | uniq" }' /etc/userdomains | sort | uniq`; do /usr/bin/clamscan -i -r /home/$i --move=/tmp/infections 2>>/dev/null; done >> /root/infections& |