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. > > 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. > > In linux it is appeared to be at /etc/cron.hourly > > > 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= 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 -- 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
pgpVERIjSulnV.pgp
Description: PGP signature