scan and delete files using cron weekly

The below scripts only scan the server from infected file. Can you help me to write something so it will delete the infected scripts/file automatically

!/bin/bash
SCANDIR="/home"
LOGFILE="/var/log/clamav/manualclamscan.log"
/usr/local/cpanel/3rdparty/bin/clamscan -i -r $SCANDIR >> $LOG_FILE

2 Replies

Deleting the flagged files automatically isn't necessarily something I'd advise, because it is possible for ClamAV to report legitimate files as malware. More info about false positives with ClamAV is available in this forum thread. If you don't wish to manually verify flagged files or have reports emailed to you, you might want to consider running a second, different scanner on any flagged files to prevent the deletion of files flagged incorrectly. Another option could be to place a delay so that the files are deleted after a set time frame, which would allow you some time to review the files to ensure they can be deleted. This article has some examples of ClamAV output that you may be able to include in your script to run as a cronjob.

Ok fine its means better to manually delete all the scripts virus files.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct