0

I'm running a php script from ssh with the following command

./script.php &

The script is a has a loop in is supposed to loop about 800,000 times (so it takes a few days to run). However it is currently stopping a couple thousand loops into the process. My error handlers are not catching any error from the script but the console reads.

Write failed: Broken pipe

Can anyone shed any light on what this message means, what kind of problem this indicates, and how I might go about tracking it down?

Update:

To summarize what the script does it selects 800,000 row from a table in my data base (hosted on the same server as the script). For each row it makes a rest call to a third party site and then writes that data to a different table in the same database (hosted on the same server as the script).

Ben Pearce
  • 6,884
  • 18
  • 70
  • 127

1 Answers1

0

Broken pipe has two causes:

  1. The program is writing to a pipe, either because it's using a function like popen() or the script's output is redirected to a pipeline, and the program reading from the pipe exits (or closes its end of the pipe for some other reason).

  2. The program is writing to a network connection, and the connection is closed by the other end.

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Hi Barmar, thanks for your response. I don' think scenario #1 applies to my script. My script does make a rest call to a third party web service (see update to question) is that writing to a network connection? – Ben Pearce Jun 04 '13 at 08:13
  • It doesn't usually happen in simple HTTP request/response connections. It's usually in long-lived connections where you're writing bulk data. – Barmar Jun 04 '13 at 08:18
  • I'm making about 800,000 rest calls and writing each result to a database. Do you think that qualifies for scenario #2? Any advice on how to debug this? – Ben Pearce Jun 04 '13 at 08:51
  • I'd expect each call to be independent, but maybe there's a problem in the way the REST library uses persistent connections, and it doesn't handle failures properly. Maybe you should post your code. – Barmar Jun 04 '13 at 08:58