![]() |
[SOLVED]cronjob for clamav - Printable Version +- Linux Lite Forums (https://www.linuxliteos.com/forums) +-- Forum: Development (https://www.linuxliteos.com/forums/forumdisplay.php?fid=7) +--- Forum: Scripting and Bash (https://www.linuxliteos.com/forums/forumdisplay.php?fid=32) +--- Thread: [SOLVED]cronjob for clamav (/showthread.php?tid=6165) |
[SOLVED]cronjob for clamav - osamu.morozumi - 05-05-2019 Hi, I'm trying to create a cron job for clamav to do a scan of the home directory once a week. I made this script in /etc/cron.weekly/ : Code: #!/bin/sh Code: # m h dom mon dow user command Am I missing a step? Is there a better way to achieve automatic weekly scans? **edit: I deleted the script in /etc/cron.weekly and instead added this cronjob to /etc/crontab Code: 0 18 * * SUN root rm -rf /var/log/clamav/freshclam.log This should update the malware database and scan the entire system every sunday at 6pm and write it to a text file I hope. Have I done this correctly and is there a way to dynamically append the current date to the name of the virus-scan text file? Re: [SOLVED]cronjob for clamav - Valtam - 05-05-2019 Try: Code: 0 18 * * SUN clamscan -r -i / | grep FOUND >> /home/osamu/virus-scan-reports/virus-scan-report.txt; mv /home/osamu/virus-scan-reports/virus-scan-report.txt /home/osamu/virus-scan-reports/virus-scan-report-`date +"%d-%m-%Y"`.txt or whatever date variables you want to include. Re: [SOLVED]cronjob for clamav - osamu.morozumi - 05-05-2019 Thanks again Jerry. Now just have to wait until 6pm to see if the job works! Re: [SOLVED]cronjob for clamav - osamu.morozumi - 05-05-2019 It took a bit of tweaking but it now works. Here is the final script: Code: 0 18 * * SUN root rm -rf /var/log/clamav/freshclam.log '%' symbols need to be escaped or they're interpreted as new lines. Re: [SOLVED]cronjob for clamav - Valtam - 05-05-2019 Nice ![]() Sent from my Mobile phone using Tapatalk |