From owner-freebsd-questions Sun Jun 16 0:53: 6 2002 Delivered-To: freebsd-questions@freebsd.org Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by hub.freebsd.org (Postfix) with ESMTP id 5068D37B403 for ; Sun, 16 Jun 2002 00:53:01 -0700 (PDT) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1]) by smtp.infracaninophile.co.uk (8.12.3/8.12.3) with ESMTP id g5G7qxnt009841; Sun, 16 Jun 2002 08:52:59 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost) by happy-idiot-talk.infracaninophile.co.uk (8.12.3/8.12.3/Submit) id g5G7qsJ3009840; Sun, 16 Jun 2002 08:52:54 +0100 (BST) Date: Sun, 16 Jun 2002 08:52:54 +0100 From: Matthew Seaman To: BSD Freak Cc: FreeBSD Questions Subject: Re: Will this cron job work? Message-ID: <20020616075254.GA9623@happy-idiot-talk.infracaninophi> References: <13a842613aacfe.13aacfe13a8426@mbox.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13a842613aacfe.13aacfe13a8426@mbox.com.au> User-Agent: Mutt/1.3.99i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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