From owner-freebsd-questions@FreeBSD.ORG Tue Oct 7 07:53:59 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 DA82216A4B3 for ; Tue, 7 Oct 2003 07:53:59 -0700 (PDT) Received: from ns2.wananchi.com (ns2.wananchi.com [62.8.64.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C1C043FBD for ; Tue, 7 Oct 2003 07:53:53 -0700 (PDT) (envelope-from wash@wananchi.com) Received: from wash by ns2.wananchi.com with local (Exim 4.22 #3 (FreeBSD)) id 1A6tDf-000JWN-9N; Tue, 07 Oct 2003 17:53:47 +0300 Date: Tue, 7 Oct 2003 17:53:47 +0300 From: Odhiambo Washington To: Free BSD Questions list Message-ID: <20031007145347.GB49707@ns2.wananchi.com> Mail-Followup-To: Odhiambo Washington , Free BSD Questions list , Matthew Seaman References: <20030930164957.GL59342@ns2.wananchi.com> <20030930180743.GA54438@happy-idiot-talk.infracaninophile.co.uk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IS0zKkzwUGydFO0o" Content-Disposition: inline In-Reply-To: <20030930180743.GA54438@happy-idiot-talk.infracaninophile.co.uk> X-Disclaimer: Any views expressed in this message,where not explicitly attributed otherwise, are mine alone!. X-Fortune: Every solution breeds new problems. X-Operating-System: FreeBSD 4.9-RC i386 X-Best-Window-Manager: Blackbox X-Mailer: Mutt 1.5.4i (2003-03-19) X-Designation: Systems Administrator, Wananchi Online Ltd. X-Location: Nairobi, KE, East Africa. X-Uptime: 5:52PM up 2 days, 5:19, 6 users, load averages: 2.58, 2.68, 3.55 User-Agent: Mutt/1.5.4i 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, 07 Oct 2003 14:54:00 -0000 --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Matthew Seaman [20030930 21:08]: wrote: > 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 g= one. > > Google could not help me so I beg to ask here: >=20 > 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) >=20 > Crontab line like: >=20 > 23 11 3,28 * * your_script >=20 > will run at 11:23am on the 3rd and 28th of each month. >=20 > > 2. Every first Thursday of the month >=20 > 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 -- >=20 > 23 11 * * Thu [ $(date +%d) -lt 8 ] && your_script >=20 > ( or >=20 > 23 11 1-7 * * [ $(date +%a) =3D "Thu" ] && your_script >=20 > but the former is probably preferable) How does that differ with the following? 23 11 * * 4 if [ `date +\%d` -le 7 ]; then /path/to/my/command; fi =20 Best regards, Odhiambo Washington Wananchi Online Ltd. ----------------------------------+----------------------------------------- Odhiambo W. wash(at)wananchi(dot)com . WANANCHI ONLINE LTD (Nairobi, KE) http://www.wananchi.com/email/ . 1ere Etage, Loita Hse, Loita St., Mobile: (+254) 722 743 223 . # 10286, 00100 NAIROBI ----------------------------------+----------------------------------------- What the hell, go ahead and put all your eggs in one basket. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Do not be afraid of those who kill the body but cannot kill the soul. Rather be afraid of the One who can destroy both soul and body in hell. Matthew 10:28 =20 --IS0zKkzwUGydFO0o Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE/gtN7n7LIsuxjem8RAuVDAJ424cMdCCEWAWS19XrkKt/eYLc3/wCfYlzF RRuYCWHhLY+gybwsN61idtM= =PApf -----END PGP SIGNATURE----- --IS0zKkzwUGydFO0o--