19. Virus scan with ClamXav
This document explains how to execute virus scanning with ClamXav in the night time. The task starts up Mac on every Saturday 3:00 AM, let ClamXav scan virus then shuts Mac down (or make it sleep).

Original Article(Japanese)


At first launch ClamXav, open preference panel and set up schedule tab. This is a sample of setting.



To update virus definitions, Mac has to be running on Saturday 3:30 AM, so make a task to start up Macintosh before that time..


(Trigger)
1. Schedule
Set "Sat" "3" "25". This time should be modified depending on the updating time of ClamXav.




(Action)
1. Start up / Shut down
Choose "start up / awake" and choose "Save and Install Schedule" from File menu.(command+shift+S) Task3 may ask you to input a password, so please input root password.
Then Macintosh will start up on each Saturday 3:25. If Mac is sleeping at that time, it will awake.





Advanced setting...
ClamXav can have only one set of paths to be scanned. If you want to switch the scanning target path every weekday, for example scan ~/Library on Mondays, ~/Documents on Tuesdays..., AppleScript is useful.
property targetDirectoryList : {"Path for target1", "Path for target2", "Path for target3"} -- Ex. {"/Applications","/Users","~/Desktop","~/Pictures"...} -- Update virus definition do shell script "/usr/local/clamXav/bin/freshclam --quiet --log=/usr/local/clamXav/share/clamav/freshclam.log; open /usr/local/clamXav/share/clamav/freshclam.log" set homePath to POSIX path of (path to home folder) set stringOfPaths to "" repeat with eachItem in targetDirectoryList if eachItem contains "~" then set eachPath to (do shell script "echo " & eachItem & " | sed -e 's/~//g'") else set eachPath to eachItem end if set stringOfPaths to stringOfPaths & space & (quoted form of eachPath) end repeat -- Scan tell application "Terminal" activate do script ("/usr/local/clamXav/bin/clamscan -r" & stringOfPaths & " --log=" & homePath & "Library/Logs/clamXav-scan.log ; open ~/Library/Logs/clamXav-scan.log") end tell


Create multiple tasks which contains "Schedule" trigger (which is set appropriate day of week and time, like "Mon" "3" "25", "Wed" "3" "25"), "Start up" action and "Run AppleScript" action and set modified script to each "Run AppleScript" action. Then Task3 runs modified script, so ClamXav scans different folders each day of week.




 

To Top and Map