Author:
Per Stenebo
Per Stenebo
Created:
2012-06-29 23:19:40
2012-06-29 23:19:40
Modified:
2017-04-16 12:59:16
2017-04-16 12:59:16
#!/bin/sh
#
# cron script to run daily antivirus scan
#
# Written 2012-06-28 by Per Stenebo.
#
# Set log file
logfile=/home/per/report-virusscan.txt
# Set target dir
targetdir=/mnt/sdb1/
# Insert empty line in logfile
echo "" >> $logfile
# Put current date and time to variable
datetime=$(date '+%Y-%m-%d %H:%M:%S')
# Write prolog to logfile
echo "clamscan on $targetdir started $datetime" >> $logfile
#-----------------
## Do scan and set log file
#clamscan -r --log=$logfile --exclude-dir="lost+found" $targetdir
## OR do scan and write screen output to logfile
## Show only infected files (-i)
clamscan -r -i --exclude-dir="lost+found" $targetdir >> $logfile
#------------------
#-----------------
## Remove excess lines with lots of ----- created if we used --log previously
## Use sed with -i switch (temp file)
#sed -i".bak" '/\-\-\-\-\-\-\-/d' $logfile
## OR grep (create temp file first)
mv $logfile ${logfile}.bak
grep -Ev '\-\-\-\-\-\-\-' ${logfile}.bak > $logfile
#-----------------
# Put current date and time to variable
datetime=$(date '+%Y-%m-%d %H:%M:%S')
# Write epilog to logfile
echo "clamscan finished $datetime" >> $logfile
#
# cron script to run daily antivirus scan
#
# Written 2012-06-28 by Per Stenebo.
#
# Set log file
logfile=/home/per/report-virusscan.txt
# Set target dir
targetdir=/mnt/sdb1/
# Insert empty line in logfile
echo "" >> $logfile
# Put current date and time to variable
datetime=$(date '+%Y-%m-%d %H:%M:%S')
# Write prolog to logfile
echo "clamscan on $targetdir started $datetime" >> $logfile
#-----------------
## Do scan and set log file
#clamscan -r --log=$logfile --exclude-dir="lost+found" $targetdir
## OR do scan and write screen output to logfile
## Show only infected files (-i)
clamscan -r -i --exclude-dir="lost+found" $targetdir >> $logfile
#------------------
#-----------------
## Remove excess lines with lots of ----- created if we used --log previously
## Use sed with -i switch (temp file)
#sed -i".bak" '/\-\-\-\-\-\-\-/d' $logfile
## OR grep (create temp file first)
mv $logfile ${logfile}.bak
grep -Ev '\-\-\-\-\-\-\-' ${logfile}.bak > $logfile
#-----------------
# Put current date and time to variable
datetime=$(date '+%Y-%m-%d %H:%M:%S')
# Write epilog to logfile
echo "clamscan finished $datetime" >> $logfile