From owner-freebsd-questions@FreeBSD.ORG Tue Sep 30 11:07:55 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4474C16A4BF for ; Tue, 30 Sep 2003 11:07:55 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id DFB7D43FE9 for ; Tue, 30 Sep 2003 11:07:52 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [127.0.0.1]) h8UI7hfs054803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 30 Sep 2003 19:07:48 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id h8UI7h3j054802; Tue, 30 Sep 2003 19:07:43 +0100 (BST) (envelope-from matthew) Date: Tue, 30 Sep 2003 19:07:43 +0100 From: Matthew Seaman To: Odhiambo Washington , Free BSD Questions list Message-ID: <20030930180743.GA54438@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Odhiambo Washington , Free BSD Questions list References: <20030930164957.GL59342@ns2.wananchi.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gKMricLos+KVdGMg" Content-Disposition: inline In-Reply-To: <20030930164957.GL59342@ns2.wananchi.com> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.60 X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on happy-idiot-talk.infracaninophile.co.uk Subject: Re: complex crontab query X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2003 18:07:55 -0000 --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 30, 2003 at 07:49:57PM +0300, Odhiambo Washington wrote: > This question was asked and was answered by Crist J. Clark some years gon= e. > Google could not help me so I beg to ask here: crontab(5) should be all you need. =20 > I would like to run a script via crontab every >=20 > 1. 3rd day and 28th day of each month (seems easy) Crontab line like: 23 11 3,28 * * your_script will run at 11:23am on the 3rd and 28th of each month. > 2. Every first Thursday of the month This one is slightly trickier -- the best you can do with crontab is either every Thursday, and add logic to your script to detect if it's on or before the 7th of the month (or conversely for the first 7 days of each month, and have the script check if it's Thursday): something like -- 23 11 * * Thu [ $(date +%d) -lt 8 ] && your_script ( or 23 11 1-7 * * [ $(date +%a) =3D "Thu" ] && your_script but the former is probably preferable) Cheers, Matthew=20 --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --gKMricLos+KVdGMg Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD4DBQE/ecZvdtESqEQa7a0RAhBBAJdYcKCx7F5vGirur/g6tWiNATprAJ97MXVE BH0tAJM7KDnou3hzLQ7mLQ== =7vdR -----END PGP SIGNATURE----- --gKMricLos+KVdGMg--