Running a PHP script as a CRON job on Linux

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dlgilbert
Forum Newbie
Posts: 6
Joined: Wed Jun 19, 2002 7:03 am
Location: Pennsylvania, USA
Contact:

Running a PHP script as a CRON job on Linux

Post by dlgilbert »

I have a small PHP script that I want to run periodically on my Linux server, but have yet to figure out how to do it.

The script has no terminal output. It simply updates a database with the status of some specified websites (it's a site monitor). I want to run it every 10 minutes or so, but if I use Lynx, the browser stays resident in memory instead of exiting once the script is done. When it runs again, another instance loads in memory. Not a good plan for something that will run every 10 minutes. :-)

So... is this something drop dead simple that I'm just missing or is there a funky trick to it?

Thanks in advance!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

call the php interpreter directly
you crontab entry would be something like

Code: Select all

0-59/10 * * * *       /usr/bin/php $HOME/myscript.php >> $HOME/tmpout 2>&1
User avatar
James Pelow
Site Admin
Posts: 51
Joined: Sat Jun 01, 2002 5:28 am
Location: Killiney, Co. Dublin, Ireland
Contact:

Or...

Post by James Pelow »

Or if you're doing it remotely use a cron job of curl or wget etc. to download the file from your http server.

-James
Post Reply