Redirect php output (cli) opens many file handles -
I have a long running php script that is running on the command line:
php myscript.php 2> Myscript.err.out & gt; Myscript.out & amp;
This opens several (system-level) file handles for some reasone - like lsof | Grep myscript.out | WC-L is growing up to kill the border.
Of course, no limit can be increased (through the ulimit ), but I really need to find this reason that in fact only one file handle will be open for that file (Increasing the Ie can only delay the problem)
As I have not trimmed at least for example - here are some features:
- Open files The following two actions are strongly related to the number:
- Temporary files (
tempnam- Store these temporary files in MongoDB
- System: SMP Debian 3.14.15-2
Is there any idea? (Or some things that I can try?)
After a lot more trys, Could drill down:
curl_setopt ($ ch, CURLOPT_FILE, fopen ('php: // stdout', 'w'));It was done in a loop (as curl example was reused - see)
So the solution is: place the handle on stdout and close it: / P>
if (isset ($ stdout) & is_resource ($ stdout)) {fclose ($ Stdout); } $ Stdout = fopen ('php: // stdout', 'w'); No reuse$ stdoutnote: directly but always stop and open it again ! (You will spoil the output!)
- Temporary files (
Comments
Post a Comment