From owner-freebsd-questions@FreeBSD.ORG Fri Dec 7 22:52:41 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B04216A417 for ; Fri, 7 Dec 2007 22:52:41 +0000 (UTC) (envelope-from kdk@daleco.biz) Received: from ezekiel.daleco.biz (southernuniform.com [66.76.92.18]) by mx1.freebsd.org (Postfix) with ESMTP id 313FE13C45D for ; Fri, 7 Dec 2007 22:52:41 +0000 (UTC) (envelope-from kdk@daleco.biz) Received: from localhost (localhost [127.0.0.1]) by ezekiel.daleco.biz (8.13.8/8.13.8) with ESMTP id lB7MqddW026709; Fri, 7 Dec 2007 16:52:39 -0600 (CST) (envelope-from kdk@daleco.biz) X-Virus-Scanned: amavisd-new at daleco.biz Received: from ezekiel.daleco.biz ([127.0.0.1]) by localhost (ezekiel.daleco.biz [127.0.0.1]) (amavisd-new, port 10024) with LMTP id cGpHodYa5O2p; Fri, 7 Dec 2007 16:52:34 -0600 (CST) Received: from archangel.daleco.biz (dsl.daleco.biz [209.125.108.70]) by ezekiel.daleco.biz (8.13.8/8.13.8) with ESMTP id lB7MqR6t026702; Fri, 7 Dec 2007 16:52:32 -0600 (CST) (envelope-from kdk@daleco.biz) Message-ID: <4759CEA6.6090403@daleco.biz> Date: Fri, 07 Dec 2007 16:52:22 -0600 From: Kevin Kinsey User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.2) Gecko/20070418 SeaMonkey/1.1.1 MIME-Version: 1.0 To: Drew Tomlinson References: <4759849F.8000603@mykitchentable.net> <475995B1.90504@daleco.biz> <47599726.1070807@mykitchentable.net> In-Reply-To: <47599726.1070807@mykitchentable.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: FreeBSD Questions Subject: Re: Help with Crontab X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Dec 2007 22:52:41 -0000 Drew Tomlinson wrote: > On 12/7/2007 10:49 AM Kevin Kinsey wrote: >> Drew Tomlinson wrote: >>> I'm trying to use cron to run a script on the first Sunday of every >>> month at 0930. I used this entry in the crontab: >>> >>> # Run 1st Sunday at 0930 - Fulls >>> 30 9 1-7 * 7 /usr/local/scripts/backup_bootstrap.sh >>> >>> Yet this script just ran on Thursday, December 6 at 0930. Why? I >>> just added it to cron so I don't know if it will run on any other days. >>> >> >> See crontab(5), which says: >> >> Note: The day of a command's execution can be specified by two fields -- >> day of month, and day of week. If both fields are restricted (ie, >> are not *), the command will be run when either field matches the current >> time. For example, ``30 4 1,15 * 5'' would cause a command to be >> run at 4:30 am on the 1st and 15th of each month, plus every Friday. > > Thank you for the reply. Now I see the light. :) So I suppose there > is no way to schedule as I wish using cron. I suspect I'll have to > modify my script to do the date checking and only execute the "meat" if > it's the right date. Well, as the sage said, "the light at the end of the tunnel is an oncoming train." Note the word "restricted" there, and realize that it means that both fields are checked and the "job" is constrained by both of them. In other words, any of these should mail you the FBSD COPYRIGHT file on Sundays only at 4:30 a.m.: 30 4 * * Sun /bin/cat /COPYRIGHT 30 4 * * 0 /bin/cat /COPYRIGHT 30 4 * * 7 /bin/cat /COPYRIGHT So, "yes, Virginia, there is a Sunday Cron." ;-) Puns, but no ill will, intended, Kevin Kinsey -- Look afar and see the end from the beginning.