I have a PHP script that retrieves list of urls from a sit开发者_运维技巧e 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
The first option would be a better go:
Should I run a cron job?
Avoid using infinite loops.
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.
A cronjob is the best alternative, but your host might not support it.
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.
精彩评论