1

I have a bash script which executes a php code and sleeps for 60 seconds and repeat same thing again

The php code does some json parsing and run bash scripts with shell_exec

I know bash inside php inside bash seems like not a best way..lets say it's for convenience.

Now the inside bash script has some sed commands and some of these sed commands sometimes throws the below errors, even though I don't see they are failing as the results are fine.

sed: couldn't write 24 items to stdout: Broken pipe
sed: couldn't write 30 items to stdout: Broken pipe
sed: couldn't write 1 item to stdout: Broken pipe
sed: couldn't write 34 items to stdout: Broken pipe

I couldn't undertand why sed couldn't write those n items. It shouldn't be disk space issue as there is plenty.

And I don't think this is file descriptors issue too, as the current soft limit 1024 should be more than enough for these scripts. But is there any way to check if the process has reached the file descriptor limit when it threw the error?

Or any suggestions/ideas what could cause this error?

closed as too broad by glenn jackman, Jeff Schaller, RalfFriedl, schily, JigglyNaga Oct 23 '18 at 16:33

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    At a guess, the client that requested the script aborted the HTTP connection. Hard to know without seeing the script and logs. – Jeff Schaller Oct 22 '18 at 15:35
  • The script has so many sed commands.. I'll try to debug where it fails and will post that part..but it's a daemon running in the server thats executing the shell script and we are just showing the results in the web page..ah I forgot about this.. there's nothing to do with http at all.. I'll edit my post – GP92 Oct 23 '18 at 7:56
  • Try to show a Minimal, Complete, Verifiable example: What command did you use to execute PHP code from the top-level bash script? Do you still see the problem if you run that command directly, rather than in a loop in a script? What are the sed commands? – JigglyNaga Oct 23 '18 at 16:33