cooldude832 Posted September 10, 2008 Share Posted September 10, 2008 I have a cron job I wrote (it gets the value of diffen't metals/currencies from yahoo) <?php $q = " SELECT CurrencyID, Abbreviation FROM `".CURRENCY_TABLE."` WHERE Active = '1' ORDER BY Name "; $r = mysql_query($q) or die(mysql_error()."<br /><br />"); if(mysql_num_rows($r) >0){ while($row = mysql_fetch_assoc($r)){ $url = "http://finance.yahoo.com/currency/convert?amt=1&from=".$row['Abbreviation']."&to=XAU&submit=Convert"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL,$url); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec ($ch); $pattern = "[yfnc_tabledata1\">]"; $split = preg_split($pattern,$data); $pattern = "[<]"; $split = preg_split($pattern,$split[4]); $rate = $split[0]; $q = "INSERT INTO `".CURRENCY_PRICE_TABLE."` (PriceTime, CurrencyID, Price) VALUES(NOW(), '".$row['CurrencyID']."', '".input_clean($rate)."')"; $r2 = mysql_query($q) or die(mysql_error()."<br /><br />".$q); curl_close($ch); } } ?> When it runs as a cron the server has no slow downs. When I run it by manually pining it in my browser and I try and load another page on my site it waits till cron is done then goes and loads the other request. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/123610-interesting-observation-and-question/ Share on other sites More sharing options...
JonnoTheDev Posted September 10, 2008 Share Posted September 10, 2008 How many records do you get from the query: SELECT CurrencyID, Abbreviation FROM `".CURRENCY_TABLE."`WHERE Active = '1' ORDER BY Name Quote Link to comment https://forums.phpfreaks.com/topic/123610-interesting-observation-and-question/#findComment-638331 Share on other sites More sharing options...
cooldude832 Posted September 10, 2008 Author Share Posted September 10, 2008 I know the job is semi slow because it takes about 1-2 seconds a request but why does it only isolate when connected on the same connection Quote Link to comment https://forums.phpfreaks.com/topic/123610-interesting-observation-and-question/#findComment-638341 Share on other sites More sharing options...
JonnoTheDev Posted September 10, 2008 Share Posted September 10, 2008 Maybe because of your mysql configuration settings: max_user_connections Quote Link to comment https://forums.phpfreaks.com/topic/123610-interesting-observation-and-question/#findComment-638361 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.