http://forums.contribs.org/index.php/topic,49499.0.htmlThere is some background from the above link.
A little bit of background.
On one of our servers, there seems to be some emails arriving with viruses, at least the antivirus software Clamav that is included with SME server thinks so.
From the results in a email to the admin account of the weekly scan for viruses, that can be set from the SME server manager panel, I have been seen email files flagged as with having viruses. I thought that it was odd because, I thought that these all emails where checked for viruses with the ClamAV software when they where received.
After looking over the emails that where suspected of having viruses. They where all spam the type of emails.
Emails with viruses or emails that I think ClamAV suspects as a virus or anything else bad has to GO (be deleted).
So I started trying to write a routine to delete these in a timely manner.
Using the clamscan program that is attached and comes with Clamav is very CPU intensive. It takes awhile to load and just the performance of it is terrible for scanning a lower number of files. clamscan is just rogue bully on CPU and Input/Output hog when scanning a large number of files and it is also a bit of a hog for a few files.
I found out the clamdcan program is more like it to my acceptance. I loads much faster. I am still learning it. But I had nothing but problems with clamdscan not processing the files, for some kind of a error [lstat() failed: Permission denied. ERROR] on each file clamdscan tried to process.
By adding the option [--fdpass] to the clamdscan program, the error went away. As far as I know, clamdscan off loads the file to the clamd service that is running the background.
The clamd service has the same resource hog problem as clamscan. I have been working on a solution to that. But we do not have a large number of emails coming in on our servers and using clamdscan does not bump up the CPU for long like clamscan does.
The way I have written this newer bash script using clamdscan does run much faster from start to stop on our servers for the number of emails being processed.
In the script you will notice that I am trying to regulate the clamd service's niceness. I have not been too successful, maybe a little in reducing the CPU of the clamd service.
And because I do not know of other effects of me changing the niceness of the clamd service. I have remarked it out. For those people that have much larger number of emails for the script to check for viruses. You can remove the comments where i have commented out the renice setting of the clamd service.
The script will follow on the next post.
If anybody knows how to scan files with clamdscan without the use of the option "--fdpass", I am very interested in how you do that. Thanks.