views:

64

answers:

5

Hey guys, I need to be able to execute either a php or jquery function to update a sql database every certain segment of time, 20 minutes for example, regardless of user activity on the website. Does anyone know the easiest way to do this? Thanks, any help is appreciated.

A: 

Use a cron job that executes a php page:

wget http://www...com/cron.php

Put your database update script in cron.php

Ian Wetherbee
+2  A: 

The easiest way would be to make a PHP script that does the update, then use a CRON Job to run it every 20 minutes.

Rocket
thanks for the quick responses guys, I've used a cron before on my own server, but i recently bought hosting on bluehost, can run cronjobs on my hosting like that?
Joe
Supposedly, yeah. http://helpdesk.bluehost.com/index.php/kb/article/000168
Rocket
+1  A: 

I guess you're looking for a cronjob on *nix (or "Scheduled Tasks" on Windows).

svens
A: 

There is a solution but you have to have access to command line. But for information: You can make a php engine. So make a infinite loop while(true), inside use a sleep function and make the proper updates.

Centurion
A: 

I got it, on bluehost I just go to cronjobs and input the path to the php script, it worked great, thanks

Joe