Koozali.org: home of the SME Server

Contribs.org Forums => Koozali SME Server 10.x => Topic started by: uli334 on September 24, 2022, 07:41:06 AM

Title: Weekly antivirus scan scheduling
Post by: uli334 on September 24, 2022, 07:41:06 AM
Hello,

is there a way to set the weekly virus-scan to a scheduled time?

Thank you for answer.
Uli
Title: Re: Weekly antivirus scan scheduling
Post by: bunkobugsy on September 24, 2022, 08:15:20 PM
if you know what you're doing, hack /etc/crontab through its template /etc/e-smith/templates/etc/crontab/clamav
first copy it to /etc/e-smith/templates-custom/etc/crontab/clamav , modify line 10, then set again weekly scans
Title: Re: Weekly antivirus scan scheduling
Post by: Jean-Philippe Pialasse on September 25, 2022, 06:08:29 PM
Code: [Select]
# cat /etc/e-smith/templates/etc/crontab/clamav
{
    my $min = substr(gmtime,14,2);

    $OUT .= "\n";
    $OUT .= "# smeserver-clamscan filesystem scan\n";
    my $ScanFreq = $clamav{FilesystemScan} || 'disabled';
    if ($ScanFreq eq 'daily') {
        $OUT .= $min."\t0\t*\t*\t*\troot\t/sbin/e-smith/smeserver-clamscan\n";
    } elsif ($ScanFreq eq 'weekly') {
        $OUT .= $min."\t0\t*\t*\t6\troot\t/sbin/e-smith/smeserver-clamscan\n";
    } else {
        $OUT .= "# disabled\n";
    }
}


the line of interest for you is
Code: [Select]
        $OUT .= $min."\t0\t*\t*\t6\troot\t/sbin/e-smith/smeserver-clamscan\n";
it is currently set to run on the 6th and last day (Saturday, as 0 is Sunday, 1 is Monday...) at hour 0:$min
where $min is the minute at which the template has been expanded the last time.

Title: Re: Weekly antivirus scan scheduling
Post by: uli334 on September 26, 2022, 03:54:49 AM
Thank you for help,

made it like you told.

Don't i have to expand this template like " /sbin/e-smith/expand-template /etc/crontab "?

Greetings, Uli
Title: Re: Weekly antivirus scan scheduling
Post by: Jean-Philippe Pialasse on September 26, 2022, 06:38:46 AM
yes you have to expand.

please do not modify the template, create a template custom or your mods will be deleted on next update
Title: Re: Weekly antivirus scan scheduling
Post by: uli334 on September 27, 2022, 05:27:31 AM
That's what i've done:

- mkdir -p /etc/e-smith/templates-custom/etc/crontab
- cp /etc/e-smith/templates/etc/crontab/clamav /etc/e-smith/templates-custom/etc/crontab
- nano /etc/e-smith/templates-custom/etc/crontab/clamav
- in the row " $OUT .= $min."\t0\t*\t*\t6\troot\t/sbin/e-smith/smeserver-clamscan\n"; " changed "t6" to "t5"
then:
- /sbin/e-smith/expand-template /etc/crontab

Right? Or some kind of failure in it?
Title: Re: Weekly antivirus scan scheduling
Post by: ReetP on September 27, 2022, 10:29:58 AM
Take a look!!

Code: [Select]
cat /etc/crontab
Also, check yoiu logs.
Title: Re: Weekly antivirus scan scheduling
Post by: uli334 on September 27, 2022, 10:56:46 AM
This is:

Code: [Select]
# smeserver-clamscan filesystem scan
49      0       *       *       5       root    /sbin/e-smith/smeserver-clamscan

Looks good!
Thank you very much for help!

Greetings, Uli