views:

236

answers:

4

I have a PHP script that retrieves list of urls from a site and stores them in a MYSQL table. I want to run the script again and again [with some time delay] and update the table. I am using codeigniter framework.

How can I do it?

  • Should I run a cron job?
  • Or should I make a start/stop page with infinte loop?

P.S my webhost is GoDaddy

+5  A: 

The first option would be a better go:

Should I run a cron job?

Avoid using infinite loops.

Sarfraz
+1 PHP is not made to act like a daemon, and the host would probably not allow it anyway.
Pekka
most host don't support cron or others shell command... if you can leave your pc online 24/7 you can call the script from it using scheduler program...
Marcx
@Pekka: yes agreed.
Sarfraz
A: 

A cronjob is the best alternative, but your host might not support it.

Marius
A: 

Most of the hosting companies have a time limit for scripts to run. So an infinite loop will not work, or will get your account suspended.

cronjobs are the best way to do it. Just set the script to run in a time interval of your choice and make sure that it doesn't take too long finish execution.

rogeriopvl
+2  A: 

If your webhost doesn't support cron, there are PLENTY of online services that will call your remote page every 1, 5, 60 minutes etc.

http://www.setcronjob.com/

Is one I've used before. Type in "online cron job" in google and you have your pick of about 20.

edit: The free version of what I linked above is limited to one call per 5 minutes. There may be other free ones that are better.

Erik
Didn't know this. Thanks :)
Jagira
Or I can call the script using another script running on my local computer.
Jagira