Cron to scan all virtual servers daily with clamav / clamscan

Hi on my cPanel servers I have a daily/nightly cron that scans all the cpanel user accounts and emails me a report each day of any infections found.

I just wondered if this can be done in a similar way for Virtualmin Virtual Servers.

Rather than scanning the whole server or just the whole home/ folder - how can all the Virtual Servers just be scanned via Cron with email reporting?

Thanks for any help.

Do you want notification emails sent to the domain owner, or to the root user?

If the root user, why wouldn’t just scanning all of /home be the right thing? (I mean, why scan each directory separately?)

There isn’t a built-in functionality for this, but it’d be easy to make a script to do it using the virtualmin command line. If it’s something more people would want, I could imagine a plugin being a reasonable way to implement such a feature. I don’t think I’d want it in core, but a plugin could add menu items and a GUI for folks who want it.

Hi thanks, scanning the home folder would be fine I guess. The email report would go to the root user or server owner, just if each Virtual Server was scanned individually instead of the whole /home, I guess a lot of files could just be skipped and just the mail/ and public_html/ or other directories that malware could find themselves in could be scanned on all the Virtual Servers.

Then when the report comes back on email each Virtual Server would be listed seperately with the scan results and if any virus/malware was found, thus just separating them out making it nice and clear what is needed to be cleaned up and which sites/files are getting attacked each day.

It would make an awesome plugin as you say. Here is how cpanel report comes back for me:

cPanel account name: myname. ----------- SCAN SUMMARY ----------- Known viruses: 4714489 Engine version: 0.98.4 Scanned directories: 145 Scanned files: 737 Infected files: 0 Data scanned: 6.94 MB Data read: 5.09 MB (ratio 1.36:1) Time: 41.344 sec (0 m 41 s)

cPanel account name: myname2.
----------- SCAN SUMMARY -----------
Known viruses: 4714489
Engine version: 0.98.4
Scanned directories: 399
Scanned files: 4240
Infected files: 0
Data scanned: 155.90 MB
Data read: 122.91 MB (ratio 1.27:1)
Time: 135.232 sec (2 m 15 s)

cPanel account name: account3.
----------- SCAN SUMMARY -----------
Known viruses: 4714489
Engine version: 0.98.4
Scanned directories: 5090
Scanned files: 15613
Infected files: 0
Data scanned: 598.80 MB
Data read: 419.11 MB (ratio 1.43:1)
Time: 416.797 sec (6 m 56 s)

cPanel account name: domain.com.
----------- SCAN SUMMARY -----------
Known viruses: 4714489
Engine version: 0.98.4
Scanned directories: 136
Scanned files: 470
Infected files: /home/domain.com/public_html/wp-includes/js/swfupload/ajax96.php: {HEX}php.base64.v23au.185.UNOFFICIAL FOUND
Data scanned: 4.91 MB
Data read: 2.59 MB (ratio 1.89:1)
Time: 9.359 sec (0 m 9 s)