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
/usr/local/cpanel/3rdparty/bin/clamscan -i -r $SCANDIR >> $LOG_FILE
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.