Clam AV weekly cron job to scan last 7 days of files in home3/* home5/*
Hello,
I am trying to make weekly cron job to scan new files in "home3/*/mail" and "home5/*/mail" folders and to remove them if infected, but only for last 7 days of new files.
Currently I have this working pretty good, but it takes too long for it to finish because it scans all files in mail folders:
/usr/local/cpanel/3rdparty/bin/clamscan -ir --remove /home4/*/mail/ /home5/*/mail/ | mail -s "Finished weekly scan and deletion of emails in folder mail" update@fmm.ba
I would like to scan only new files and make it run once a week, and maybe daily in future.
Currenty it scans directories: 40966 and files: 3076744. I would like to speed things up and make it use less resources.
Does anybody know how can I achieve this?
I have found this, but not tested:
find /home4/*/mail/ /home5/*/mail/ -ctime -1 -type f -print0 | xargs -0 /usr/local/cpanel/3rdparty/bin/clamscan --remove mail -s "Finished weekly scan and deletion of emails in folder mail" update@fmm.ba
-
Hey there! I'm not sure that "ctime -1" is going to give you the results you want. You might want to try "mtime 7" instead of that ctime option, as that would grab any files between now and 7 days old. You can also just run the first half of the command, slightly modified, to see if the output is what you expect, before passing it to the clamscan commands: find /home4/*/mail/ /home5/*/mail/ -mtime 6 -type f > output.file
That would create a file named "output.file" so you can examine the contents.0 -
I think I've did it with this two cron jobs: 0 5 * * 1-6 find /home4/*/mail /home5/*/mail -ctime -8 -type f -print > /home3/lista_8_dana.txt | mail -s "List is created" update@fmm.ba 30 5 * * 7 /usr/local/cpanel/3rdparty/bin/clamscan --infected --remove --scan-mail --phishing-sigs --phishing-scan-urls --algorithmic-detection --scan-pe --scan-elf --scan-ole2 --scan-pdf --scan-html --file-list=/home3/lista_8_dana.txt | mail -s "Scanning completed" update@fmm.ba 0
Please sign in to leave a comment.
Comments
2 comments