[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#944110: anacron: Incorrect behavoiur when using @monthly period_name



Package: anacron
Version: 2.3-28
Severity: normal

Dear Maintainer,

I see that @monthly is not a feature of anacron upstream, but it belongs to a debian patch.

I have found that @monthly period_name doesnt work well sometimes.

Let's see an example: I have an job that was last executed by anacron on the first of october. The expected behaviour would be that the next execution will happen on the first of november.
But the truth is that the next execution happens on the 31st of october.

Looking at lock.c code I see:

 if (jr->named_period)
        {
            int period = 0, bypass = 0;
            switch (jr->named_period)
            {
                case 1:
                    period = days_last_month ();
                    bypass = days_this_month ();
                    break;
                case 2:
                    period = days_last_year ();
                    bypass = days_this_year ();
                    break;
                default:
                    die ("Unknown named period for %s (%d)", jr->ident, jr->named_period);
            }
            if (day_delta < period && day_delta != bypass)
            {
                /* Job is still too young */
                xclose (jr->timestamp_fd);
                return 0;
            }
        }



Last execution (with YYYYMMDD notation): 20191001

Current day: 20191031

day_delta=30

period=30 (Number of days in september)

bypass=31 (Number of days in octuber)

(day_delta < period && day_delta != bypass) = (30 < 30 && 30 !=31) = (FALSE && TRUE) = FALSE, so the job is executed today


In this case the job is run on the 1st and on the 31st day of october. Two times in a month. The next one will be at the end of november. I think this is wrong. If first run is on 1st day it should be again the first day of following months, assuming that the machine is turned up everyday.


Not sure about (day_delta < period && day_delta != bypass). It doesn't work in this case, but it doesnt work with another dates: (i.e.: last execution on january 31st, won't run on february, but on the first of march))



Can this be fixed, please?


Thank you and regards.





-- System Information:
Debian Release: 10.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 4.19.0-6-686-pae (SMP w/2 CPU cores)
Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8), LANGUAGE=es_ES.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages anacron depends on:
ii  debianutils  4.8.6.1
ii  libc6        2.28-10
ii  lsb-base     10.2019051400

Versions of packages anacron recommends:
ii  cron [cron-daemon]           3.0pl1-134
ii  rsyslog [system-log-daemon]  8.1901.0-1

Versions of packages anacron suggests:
ii  exim4-daemon-light [mail-transport-agent]  4.92-8+deb10u3
ii  powermgmt-base                             1.34

-- no debconf information


Reply to: