Date: Sun, 16 Jun 2002 08:52:54 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: BSD Freak <bsd-freak@mbox.com.au> Cc: FreeBSD Questions <freebsd-questions@FreeBSD.ORG> Subject: Re: Will this cron job work? Message-ID: <20020616075254.GA9623@happy-idiot-talk.infracaninophi> In-Reply-To: <13a842613aacfe.13aacfe13a8426@mbox.com.au> References: <13a842613aacfe.13aacfe13a8426@mbox.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jun 16, 2002 at 12:31:18PM +1000, BSD Freak wrote: > I have a quick question. I need a cron job to run every 4 week (28 > days) on a Monday (ie every 4th Monday). Will the following do it: > > 1 8 * * 1/4 root /mydir/myscript > > > With the above I am trying to run /mydir/myscript at 8:01am every 4th > Monday. Will it work? No --- that will run your job every Monday. There isn't any facility in cron to run jobs based on week number. The easiest way to achieve what you want is to use cron to run your job every Monday: 1 8 * * 1 root /mydir/myscript And modify your script to test that the week number of the year is a multiple of 4 or else exit immediately by adding something like this at the top: weekno=$(date +%U) if [ $(($weekno % 4)) != 0 ] ; then exit fi Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way Tel: +44 1628 476614 Marlow Fax: +44 0870 0522645 Bucks., SL7 1TH UK To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020616075254.GA9623>