Date: Thu, 2 Aug 2001 15:59:14 +0300 From: Odhiambo Washington <wash@wananchi.com> To: freebsd-questions@FreeBSD.ORG Subject: Re: Crontab - Biweekly events? Message-ID: <20010802155914.A36173@everest.wananchi.com> In-Reply-To: <20010802154725.B24967@everest.wananchi.com> References: <thomas@pbegames.com> <5.1.0.14.2.20010719175024.02510170@pbegames.com> <200107192337.JAA04489@tungsten.austclear.com.au> <20010802154725.B24967@everest.wananchi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Odhiambo Washington <wash@wananchi.com> [20010802 15:51]: writing on the = subject 'Re: Crontab - Biweekly events?' > * Tony Landells <ahl@austclear.com.au> [20010720 02:37]: writing on the s= ubject 'Re: Crontab - Biweekly events?' > Tony>=20 > Tony> thomas@pbegames.com said: > Tony> > I have a task I want to run every other week on a specific day, s= ay > Tony> > Tuesday. I can't see a way to convince cron to do this. Anyone kn= ow > Tony> > how?=20 > Tony>=20 > Tony> You can't. Cron doesn't support this. > Tony>=20 > Tony> However, what you can do is wrap your stuff in a script that either > Tony> creates a "flag" file somewhere (if it doesn't exist) and runs your > Tony> stuff or deletes the flag file (if it exists) and exits. Then run > Tony> that every Tuesday from crontab. > Tony>=20 > Tony> Alternatively, you can use "at" to schedule the job initially, and > Tony> then have it reschedule itself for two weeks time. You probably > Tony> want it to email you a reminder that it's rescheduled itself too... > Tony>=20 > Tony> Actually, I like the first one a lot, since you could also use it > Tony> for every second day, month, ... > Tony>=20 > Tony> Actually, a generic "wrapper" could even be made to run the task > Tony> every <arbitrary number> of days/weeks/years/... >=20 > Long time ago (not quite long really) someone called Crist J. Clark posted > something that would seem to diagree with Tony's assertion that this > cannot be done in a crontab. I will paste here the discussion verbatim: >=20 > <snip> > > > I am looking for a crontab entry that runs my command on > > > the first thursday of every month at 6 am. I thought the > > > following would work but it doesn't: > > > > > > > AFAIK, this cannot be done with a crontab entry. However, you may be > > able to wrap /path/to/my/command with a script that exits if the day of= the > > month is greater than 7, and then use a crontab entry that simply > > specifies to run on every thursday. >=20 > No need for a wrapper, just put it all in the crontab, > 0 6 * * 4 if [ `date +\%d` -le 7 ]; then /path/to/my/command; fi >=20 > -- > Crist J. Clark cjclark@alum.mit.edu >=20 > </snip> >=20 >=20 > Maybe that will give this guy an insight. > I've been looking into running a cron job like this and was attempting > this, although it's not yet worked >=20 >=20 > DATE=3D`date +\%w` # Will give me the numerical date.=20 >=20 > alligator# bash > wash:/home/wash# DATE=3D`date +\%w` > wash:/home/wash# echo $DATE > 4 >=20 > So today is Thursday, the 4th day. Tuesday is then the 2nd day. >=20 > Can't we then do something like >=20 > if [ $DATE =3D "2" ]; then /run/some/command ; fi >=20 > to make his command run every Tuesday?? >=20 > Can't that be made to work? >=20 > Please lemme know. As a rejoinder, suppose it can work, then he can have two instances of the same running on different days. I am suggesting that because I am not so a scripting guru. The gurus will definately have a better way of doing this;-)=20 -Wash -- Odhiambo Washington Wananchi Online Ltd., wash@wananchi.com 1st Flr Loita Hse. Tel: 254 2 313985 Loita Street., Fax: 254 2 313922 PO Box 10286,00100-NAIROBI,KE. You must take action now that will move you towards your goals. Develop a= =20 sense of urgency in your life.=20 -Les Brown=20 --7JfCtLOvnd9MIVvH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE7aU6in7LIsuxjem8RAujEAKCZFIdbTpfwYUeu/XiiK5yUkXWMxwCePdbs ez/JC80lm1i8fwdVPJouiSA= =gNrl -----END PGP SIGNATURE----- --7JfCtLOvnd9MIVvH-- 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?20010802155914.A36173>
