From owner-freebsd-questions@FreeBSD.ORG Mon Jul 5 15:01:53 2004 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 BDFAE16A4CE; Mon, 5 Jul 2004 15:01:53 +0000 (GMT) Received: from smtp.infracaninophile.co.uk (ns0.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 40FFD43D55; Mon, 5 Jul 2004 15:01:52 +0000 (GMT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1])i65F1kC3009789 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 5 Jul 2004 16:01:46 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id i65F1kTE009775; Mon, 5 Jul 2004 16:01:46 +0100 (BST) (envelope-from matthew) Date: Mon, 5 Jul 2004 16:01:46 +0100 From: Matthew Seaman To: Taulant Galimuna Message-ID: <20040705150146.GA40808@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Taulant Galimuna , freebsd-newbies@freebsd.org, freebsd-questions@freebsd.org References: <20040704071004.E11E8AE097@nezlok.unixathome.org> <060b01c4629e$b60e45c0$0302a8c0@webmaster2> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qMm9M+Fa2AknHoGS" Content-Disposition: inline In-Reply-To: <060b01c4629e$b60e45c0$0302a8c0@webmaster2> User-Agent: Mutt/1.5.6i X-Greylist: Message not sent from an IPv4 address, not delayed by milter-greylist-1.5.3 (smtp.infracaninophile.co.uk [0.0.0.0]); Mon, 05 Jul 2004 16:01:47 +0100 (BST) X-Virus-Scanned: clamd / ClamAV version devel-20040705, clamav-milter version 0.74a on smtp.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk cc: freebsd-newbies@freebsd.org cc: freebsd-questions@freebsd.org Subject: Re: cron.daily and cron.hourly 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: Mon, 05 Jul 2004 15:01:54 -0000 --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 05, 2004 at 04:45:27PM +0200, Taulant Galimuna wrote: > I had a problem with my web-server that I already solved. But now I have = to > execute a PHP file on my FreeBSD server every hour, to get the needed > updates from database. >=20 > I know I need a shell script to execute that file and have to put this > script to some directory that would execute it every hour. >=20 > In linux it is appeared to be at /etc/cron.hourly >=20 >=20 > but in FreeBSD I can't locate it. There isn't anything like cron.hourly under FreeBSD. (There is /etc/periodic for running system maintenance tasks, but that runs at most daily.) What you need to do is run your script out of the crontab of the appropriate user. Since this is all web related I'm going to use use 'www' as an example. First, read the crontab(5) man page (ie. type 'man 5 crontab' -- if you just type 'man crontab' you'll get the crontab(1) man page, which is worth reading as well) Then to set up the cron job, as root do: # crontab -e -u www which will plunk you into an editor opened on the www users' crontab file. Add a line like: @hourly /your/php/script/here If that script generates any output to stdout or stderr, it will be e-mailed to the www user. Supposing you don't want that, either redirect all output to /dev/null: @hourly /your/php/script/here >/dev/null 2>&1 or use the MAILTO=3D variable as described in crontab(5). Also note that lots of people come adrift the first time the use cron(8) because cron doesn't set up the environment like a login session. In particular, make sure that you explicitly set the $PATH at the top of your script, or you will get a load of "command not found" errors. Cheers, Matthew --=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 --qMm9M+Fa2AknHoGS Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFA6W1aiD657aJF7eIRAnH0AJ4wPAYGGs3o5TmlPyQtGZQO63aP2QCeKp56 K3uvCfEOVLlpvQfFLRg+NdM= =4bZT -----END PGP SIGNATURE----- --qMm9M+Fa2AknHoGS--