Koozali.org: home of the SME Server

Weekly antivirus scan scheduling

Offline uli334

  • ***
  • 128
  • +0/-0
Weekly antivirus scan scheduling
« 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

Offline bunkobugsy

  • *
  • 279
  • +4/-0
Re: Weekly antivirus scan scheduling
« Reply #1 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
« Last Edit: September 24, 2022, 08:30:40 PM by bunkobugsy »

Online Jean-Philippe Pialasse

  • *
  • 2,762
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Weekly antivirus scan scheduling
« Reply #2 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.


Offline uli334

  • ***
  • 128
  • +0/-0
Re: Weekly antivirus scan scheduling
« Reply #3 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

Online Jean-Philippe Pialasse

  • *
  • 2,762
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Weekly antivirus scan scheduling
« Reply #4 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

Offline uli334

  • ***
  • 128
  • +0/-0
Re: Weekly antivirus scan scheduling
« Reply #5 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?

Offline ReetP

  • *
  • 3,731
  • +5/-0
Re: Weekly antivirus scan scheduling
« Reply #6 on: September 27, 2022, 10:29:58 AM »
Take a look!!

Code: [Select]
cat /etc/crontab
Also, check yoiu logs.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline uli334

  • ***
  • 128
  • +0/-0
Re: Weekly antivirus scan scheduling
« Reply #7 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