2

Possible Duplicate:
PHP: running scheduled jobs (cron jobs)

I need to update a database every 20 mins lets say. (ie. add 50 to 'X' column, subtract 20 form 'y' column, preform an equation based on time on 'z' column, etc.) I have the necessary update in a update.php page but how would i go about calling that page every 20 minutes (short of scheduling a task on a computer)? or is there a better way to do this?

Thanks

Community
  • 1
  • 1
Glen020
  • 187
  • 1
  • 12

3 Answers3

4

Linux

This should be done as a cron job or alternatively using at to schedule the job. I have written a PHP wrapper for the at command that you could use for this purpose: https://github.com/treffynnon/PHP-at-Job-Queue-Wrapper

Windows

You need to use Scheduled Tasks. Here is a link to an old article I wrote about moving Linux cronjobs to a Windows machine: http://blog.simonholywell.com/post/374209271/linux-to-windows-server-migrating-and-securing-your-cron

Treffynnon
  • 21,365
  • 6
  • 65
  • 98
  • Argh, Problem is it's being hosted on a Hostmonster DB. no way's around this, eh? – Glen020 Aug 26 '11 at 15:40
  • Perhaps you could use something like this service to work around the problem: http://www.onlinecronjobs.com/ or you could possible use Google App Engine as I think it has scheduled tasks now. – Treffynnon Aug 26 '11 at 15:53
2

Where does this page live? If it's on a Linux box, use a cron job. If it's on a Windows machine, use a Scheduled Task.

Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
0

The answer to your question is no, you're going to have to schedule a task. Basically because this situation is exactly what it is made for!

On Linux you can use a cron job. On windows it is done with a scheduled task

helloandre
  • 10,541
  • 8
  • 47
  • 64