you can call a web browser to load a web page via cron and therefore run the js (ajax), but i have to agree with Weedpacket about the suitability of this approach. Perhaps if you told us what you where trying to achieve some one may come up with a better solution
Using Ajax to refresh/redirect page
dagon;10891664 wrote:you can call a web browser to load a web page via cron and therefore run the js (ajax), but i have to agree with Weedpacket about the suitability of this approach. Perhaps if you told us what you where trying to achieve some one may come up with a better solution
Every hour the script is run.
The script selects data from a database- on average 3000 results are returned.
Each row will have an e-mail and a URL. The script retrieves data from the URL, builds an e-mail and sends it.
nothing in what it does requires ajax, it could be all php then calling the script via cron using php on the command line would be a simple task.
dagon;10891751 wrote:nothing in what it does requires ajax, it could be all php then calling the script via cron using php on the command line would be a simple task.
The script is all php and is called on the command line using cron.
The reason for me needing to refresh the page is down to the script timing out and eating up server resources.
set_time_limit(0);
dagon;10891763 wrote:set_time_limit(0);
That works in stopping PHP from timing out however, with 3000 results each needing on average 2 seconds processing time, the database and http server soon die!
define 'die', you can have a db connection open for ever and running from the command line there is no http server involved
If you have 3000 rows and 2 secs per row, this is going to take 100+ minutes to run, so you can't have it run every hour if you do it in one script.
If you really need that much time for each row, you will have to have 2 or 3 scripts running at the same time to process it all in one hour.
Hopefully this is on a dedicated server.
at work we send 2-10 a second depending on size (average is 60k as we embed all images) they are running in a background task, php on the command line never had a time out issue. Of course this is our machine(s), cant see any host out there allowing it on anything but a dedicated box.
So is it 2 seconds per row or 10-30 seconds per row?
I hate to think what it needs to do every hour that takes so long with so little data. If it took 2 seconds to do all 3000 rows it would make more sense.
Weedpacket;10891779 wrote:So is it 2 seconds per row or 10-30 seconds per row?
I hate to think what it needs to do every hour that takes so long with so little data. If it took 2 seconds to do all 3000 rows it would make more sense.
It's for private business owners. It queries external RSS feeds which provide vital data. So it can take up to 30 seconds per row if the feed is slow to respond.
Would looking into multi-thread simulation help?
See Halfabee's most recent comment.