Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Dec 2007 16:52:22 -0600
From:      Kevin Kinsey <kdk@daleco.biz>
To:        Drew Tomlinson <drew@mykitchentable.net>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Help with Crontab
Message-ID:  <4759CEA6.6090403@daleco.biz>
In-Reply-To: <47599726.1070807@mykitchentable.net>
References:  <4759849F.8000603@mykitchentable.net> <475995B1.90504@daleco.biz> <47599726.1070807@mykitchentable.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4759CEA6.6090403>