From owner-freebsd-hackers Tue Apr 15 18:53:26 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id SAA27908 for hackers-outgoing; Tue, 15 Apr 1997 18:53:26 -0700 (PDT) Received: from phobos.illtel.denver.co.us (abelits@phobos.illtel.denver.co.us [207.33.75.1]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id SAA27903 for ; Tue, 15 Apr 1997 18:53:22 -0700 (PDT) Received: from localhost (abelits@localhost) by phobos.illtel.denver.co.us (8.8.5/8.6.9) with SMTP id SAA10614; Tue, 15 Apr 1997 18:55:26 -0700 Date: Tue, 15 Apr 1997 18:55:25 -0700 (PDT) From: Alex Belits To: Shawn Carey cc: "Daniel O'Callaghan" , freebsd-hackers@freebsd.org Subject: Re: crontab question In-Reply-To: <3354143F.41C67EA6@servtech.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Tue, 15 Apr 1997, Shawn Carey wrote: > > 0 14 1-7 * 0 root mail -s "cron test" root > > will run on the first Sunday. > > [...] > > But won't it run every day of the first week, and every Sunday after > that also? > Only one of the two day fields needs to match in order for cron to run > the command. Since I'll be using this to automate monthly backups, I'd > rather not accidentally chew on tapes that happen to be in the drives at > an unlucky moment! :-) > > It seems to me that what I need is for cron to logically AND the > day-of-week and day-of-month fields instead of using logical OR. Is > there any low down, dirty way to simulate this (short of hacking cron)? 0 14 1-7 * * root date | grep Sun >/dev/null && mail -s "cron test" root and last Sunday: 0 14 22-31 * * root [ `date|cut -f3 -d' '` = `cal|cut -f1 -d' '|grep -v ^\$|tail -1` ] && mail -s "cron test" root -- Alex