Bug 21152

Summary: @monthly entry in crontab is run every day
Product: Base System Reporter: Andre Albsmeier <Andre.Albsmeier>
Component: binAssignee: Mike Heffner <mikeh>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1-STABLE   
Hardware: Any   
OS: Any   

Description Andre Albsmeier 2000-09-09 20:40:01 UTC
Crontab entries using @monthly are run daily

How-To-Repeat: 
Put an @monthly entry in crontab and wait one day
Comment 1 Mike Heffner freebsd_committer freebsd_triage 2001-08-03 01:31:00 UTC
Responsible Changed
From-To: freebsd-bugs->mikeh

I'll look into this. FWIW, it also appears there is a problem with @weekly (misc/29389).
Comment 2 mheffner 2001-08-15 04:45:24 UTC
Can you see whether the following, untested, patch works? It should fix the
@monthly and @weekly entries. Also, it should fix the @yearly/@annually entry
so that it doesn't execute daily during January.


Thanks,

Mike

-- 
  Mike Heffner         <mheffner@[acm.]vt.edu>
  Fredericksburg, VA       <mikeh@FreeBSD.org>




Index: entry.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/cron/lib/entry.c,v
retrieving revision 1.14
diff -u -r1.14 entry.c
--- entry.c     2001/07/18 11:49:45     1.14
+++ entry.c     2001/08/15 03:40:59
@@ -156,6 +156,7 @@
                        bit_set(e->dom, 0);
                        bit_set(e->month, 0);
                        bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1));
+                       e->flags |= DOW_STAR;
                } else if (!strcmp("monthly", cmd)) {
                        Debug(DPARS, ("load_entry()...monthly shortcut\n"))
                        bit_set(e->minute, 0);
@@ -163,11 +164,13 @@
                        bit_set(e->dom, 0);
                        bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1));
                        bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1));
+                       e->flags |= DOW_STAR;
                } else if (!strcmp("weekly", cmd)) {
                        Debug(DPARS, ("load_entry()...weekly shortcut\n"))
                        bit_set(e->minute, 0);
                        bit_set(e->hour, 0);
                        bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1));
+                       e->flags |= DOM_STAR;
                        bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1));
                        bit_set(e->dow, 0);
                } else if (!strcmp("daily", cmd) || !strcmp("midnight", cmd)) {
Comment 3 Andre Albsmeier 2001-08-15 08:48:27 UTC
On Tue, 14-Aug-2001 at 23:45:24 -0400, Mike Heffner wrote:
> Can you see whether the following, untested, patch works? It should fix the
> @monthly and @weekly entries. Also, it should fix the @yearly/@annually entry

Done! I have added weekly and monthly test entries in my crontab
and we will see.

Thanks so far,

	-Andre
Comment 4 mheffner 2001-08-16 01:10:57 UTC
On 15-Aug-2001 Andre Albsmeier wrote:
| On Tue, 14-Aug-2001 at 23:45:24 -0400, Mike Heffner wrote:
|> Can you see whether the following, untested, patch works? It should fix the
|> @monthly and @weekly entries. Also, it should fix the @yearly/@annually
|> entry
| 
| Done! I have added weekly and monthly test entries in my crontab
| and we will see.

I've tested these by changing the date back and forth, and as far as I can tell
they're correct. I'll probably commit them within the next few days.

Mike

-- 
  Mike Heffner         <mheffner@[acm.]vt.edu>
  Fredericksburg, VA       <mikeh@FreeBSD.org>
Comment 5 Andre Albsmeier 2001-08-16 06:19:00 UTC
On Wed, 15-Aug-2001 at 20:10:57 -0400, Mike Heffner wrote:
> 
> On 15-Aug-2001 Andre Albsmeier wrote:
> | On Tue, 14-Aug-2001 at 23:45:24 -0400, Mike Heffner wrote:
> |> Can you see whether the following, untested, patch works? It should fix the
> |> @monthly and @weekly entries. Also, it should fix the @yearly/@annually
> |> entry
> | 
> | Done! I have added weekly and monthly test entries in my crontab
> | and we will see.
> 
> I've tested these by changing the date back and forth, and as far as I can tell

This I didn't want to do since I don't have machines for playing at
the moment. But it seems the @monthly entry didn't get executed
last night as it did before :-)

> they're correct. I'll probably commit them within the next few days.

Might be nice to see this fix go in 4.4 before release :-)

Thanks,

	-Andre
Comment 6 Mike Heffner freebsd_committer freebsd_triage 2001-08-18 15:39:47 UTC
State Changed
From-To: open->closed

Fix MFC'd.