<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How To Run A PHP Script In The Background</title>
	<atom:link href="http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/feed/" rel="self" type="application/rss+xml" />
	<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/</link>
	<description>A blog about web development, software business, and WordPress</description>
	<lastBuildDate>Mon, 21 May 2012 06:20:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Gaurang</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-200166</link>
		<dc:creator>Gaurang</dc:creator>
		<pubDate>Mon, 21 May 2012 06:20:12 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-200166</guid>
		<description>Hello,

Thank you so much for this post. since 2 days, i was looking for this kind of thind and finally got from your post and it works for me......

Excellent !</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Thank you so much for this post. since 2 days, i was looking for this kind of thind and finally got from your post and it works for me&#8230;&#8230;</p>
<p>Excellent !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rochelle</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-200129</link>
		<dc:creator>Rochelle</dc:creator>
		<pubDate>Fri, 18 May 2012 09:46:05 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-200129</guid>
		<description>Hi! Thank you for this! I&#039;d been trying everything for hours and this is the only one that worked! :)</description>
		<content:encoded><![CDATA[<p>Hi! Thank you for this! I&#8217;d been trying everything for hours and this is the only one that worked! :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jānis Elsts</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-199541</link>
		<dc:creator>Jānis Elsts</dc:creator>
		<pubDate>Fri, 13 Apr 2012 14:21:17 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-199541</guid>
		<description>The script does, in fact, use POST. URL parameters are used to pass arguments to the backgroundPost() function and are converted to POST fields before the HTTP request is sent.

In retrospect, doing it that way may have been a bad design choice. It would be better to just pass the arguments as an associative array, then convert them to a query string with http_build_query().</description>
		<content:encoded><![CDATA[<p>The script does, in fact, use POST. URL parameters are used to pass arguments to the backgroundPost() function and are converted to POST fields before the HTTP request is sent.</p>
<p>In retrospect, doing it that way may have been a bad design choice. It would be better to just pass the arguments as an associative array, then convert them to a query string with http_build_query().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lakey</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-199522</link>
		<dc:creator>Lakey</dc:creator>
		<pubDate>Thu, 12 Apr 2012 14:51:57 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-199522</guid>
		<description>Great script, was looking for something like this for a while, got a question though.

With the HTTP request you can send information using URL parameters, but is it also possible to send information with a POST and how would one do that?</description>
		<content:encoded><![CDATA[<p>Great script, was looking for something like this for a while, got a question though.</p>
<p>With the HTTP request you can send information using URL parameters, but is it also possible to send information with a POST and how would one do that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jānis Elsts</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-198704</link>
		<dc:creator>Jānis Elsts</dc:creator>
		<pubDate>Tue, 13 Mar 2012 13:34:33 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-198704</guid>
		<description>I tried your script on my local server and the zwrite.php script was called exactly 100 times. However, I had to modify it to create a new log file for each $x/$y combination, as otherwise some runs would not be logged. Basically, I added this line to zwrite.php:

[sourcecode lang=&quot;php&quot;]
file_put_contents(sprintf(&#039;logs/%2d-%2d.txt&#039;, $x, $y), $x. &#039;, &#039;. $y);
[/sourcecode]

All 100 files were successfully created in my &quot;logs&quot; directory. 

This seems to indicate that the script is not the problem, but rather that something is wrong with your server (e.g. it might be unable to handle so many requests in such a short time).</description>
		<content:encoded><![CDATA[<p>I tried your script on my local server and the zwrite.php script was called exactly 100 times. However, I had to modify it to create a new log file for each $x/$y combination, as otherwise some runs would not be logged. Basically, I added this line to zwrite.php:</p>
<pre class="brush: php; title: ; notranslate">
file_put_contents(sprintf('logs/%2d-%2d.txt', $x, $y), $x. ', '. $y);
</pre>
<p>All 100 files were successfully created in my &#8220;logs&#8221; directory. </p>
<p>This seems to indicate that the script is not the problem, but rather that something is wrong with your server (e.g. it might be unable to handle so many requests in such a short time).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: egiannopo</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-198612</link>
		<dc:creator>egiannopo</dc:creator>
		<pubDate>Sun, 11 Mar 2012 08:58:21 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-198612</guid>
		<description>Hi Janis,

I have try anything (even with mysql as log, or to add a delay between requests). I have upload the scripts (zip) at https://www.yousendit.com/download/M3Brek9qays3bURsZThUQw
in case that anybody find something wrong in my code.

ps. My case is, when I get a stock market value change, I have to do calculations  and send an XML to different clients. So if I have 10 stock-market changes, at the same time (xloop) and 10 clients (yloop) do calc and send xml, for any pair for stock-client (zwrite). All these in 1 sec maximum.

Thanks for your help
EG</description>
		<content:encoded><![CDATA[<p>Hi Janis,</p>
<p>I have try anything (even with mysql as log, or to add a delay between requests). I have upload the scripts (zip) at <a href="https://www.yousendit.com/download/M3Brek9qays3bURsZThUQw" rel="nofollow">https://www.yousendit.com/download/M3Brek9qays3bURsZThUQw</a><br />
in case that anybody find something wrong in my code.</p>
<p>ps. My case is, when I get a stock market value change, I have to do calculations  and send an XML to different clients. So if I have 10 stock-market changes, at the same time (xloop) and 10 clients (yloop) do calc and send xml, for any pair for stock-client (zwrite). All these in 1 sec maximum.</p>
<p>Thanks for your help<br />
EG</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jānis Elsts</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-198609</link>
		<dc:creator>Jānis Elsts</dc:creator>
		<pubDate>Sun, 11 Mar 2012 07:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-198609</guid>
		<description>Huh, that&#039;s interesting. Try also adding logging to the xloop.php and yloop.php scripts to see how many of the x &amp; y loop iterations get executed on that level. It could help figure out what part of the the xloop.php -&gt; yloop.php -&gt; zwrite.php chain is causing the problem.</description>
		<content:encoded><![CDATA[<p>Huh, that&#8217;s interesting. Try also adding logging to the xloop.php and yloop.php scripts to see how many of the x &#038; y loop iterations get executed on that level. It could help figure out what part of the the xloop.php -&gt; yloop.php -&gt; zwrite.php chain is causing the problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: egiannopo</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-198585</link>
		<dc:creator>egiannopo</dc:creator>
		<pubDate>Sat, 10 Mar 2012 16:22:44 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-198585</guid>
		<description>Thanks for the useful trick.
I have try some tests, and I found a strange situation.
My Test procedure:
3 scripts (xloop.php, yloop.php &amp; zwrite.php)
xloop.php calls 10 times (in a loop) the yloop.php script passing the x (1 to 10).
yloop.php calls 10 times (in a loop) the zwrite.php script passign the x(that get from xloop) &amp; y (1..10 &amp; 1..10).
z.php gets the 2 params (x &amp; y) that saved  in a log file.

With simple maths, the zwrite script must run 100 times (10X10), and we expect to find 100 lines in our log file.
But nop!!!

Every time I run the xloop, I found less than 100 entries in the log (the lowest till now is 59)

I have try also, to create a different log file (log-X-Y.txt) in case that the system or the disk can handle 100 IO in the same millisecond for the same file.
But the results are similar. The log files in directory is &lt; 100.

Where is the problem? Some request are lost? The system can&#039;t handle to write 100 text files in the same millisecond? 

thoughts are welcome!!!
Thanks in advance
EG</description>
		<content:encoded><![CDATA[<p>Thanks for the useful trick.<br />
I have try some tests, and I found a strange situation.<br />
My Test procedure:<br />
3 scripts (xloop.php, yloop.php &amp; zwrite.php)<br />
xloop.php calls 10 times (in a loop) the yloop.php script passing the x (1 to 10).<br />
yloop.php calls 10 times (in a loop) the zwrite.php script passign the x(that get from xloop) &amp; y (1..10 &amp; 1..10).<br />
z.php gets the 2 params (x &amp; y) that saved  in a log file.</p>
<p>With simple maths, the zwrite script must run 100 times (10X10), and we expect to find 100 lines in our log file.<br />
But nop!!!</p>
<p>Every time I run the xloop, I found less than 100 entries in the log (the lowest till now is 59)</p>
<p>I have try also, to create a different log file (log-X-Y.txt) in case that the system or the disk can handle 100 IO in the same millisecond for the same file.<br />
But the results are similar. The log files in directory is &lt; 100.</p>
<p>Where is the problem? Some request are lost? The system can&#039;t handle to write 100 text files in the same millisecond? </p>
<p>thoughts are welcome!!!<br />
Thanks in advance<br />
EG</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: analytical</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-198452</link>
		<dc:creator>analytical</dc:creator>
		<pubDate>Sat, 03 Mar 2012 22:41:25 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-198452</guid>
		<description>Where could I input the url I want to load?  Or what variable should I set, I want to use this with one variable at first, then from an array of urls.</description>
		<content:encoded><![CDATA[<p>Where could I input the url I want to load?  Or what variable should I set, I want to use this with one variable at first, then from an array of urls.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Running a PHP script in the background &#8212; Matt Geri</title>
		<link>http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/comment-page-3/#comment-197343</link>
		<dc:creator>Running a PHP script in the background &#8212; Matt Geri</dc:creator>
		<pubDate>Fri, 20 Jan 2012 10:21:49 +0000</pubDate>
		<guid isPermaLink="false">http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/#comment-197343</guid>
		<description>[...] the first. If you want a very good tutorial on how to do the above two methods, then check out this tutorial on w-shadow.com. It gives you code samples and explains quite a bit of [...]</description>
		<content:encoded><![CDATA[<p>[...] the first. If you want a very good tutorial on how to do the above two methods, then check out this tutorial on w-shadow.com. It gives you code samples and explains quite a bit of [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

