I have a cron job that runs a shell script that executes a php script. It runs every day, sends some email, and writes to stdout (which is redirected to a log file in the shell script).

It looks as though this process has finished, today, but not exited (or whatever the correct terminology is!).

$ ps -ejH
10756 10756 10756 ?        00:00:00   sh
10760 10756 10756 ?        00:00:00     automail.sh
10766 10756 10756 ?        00:03:57       php

The process with id 10766 has consumed just under 4 minutes of CPU time. From an interactive top session, I get the following:

10766 root      20   0 40640 6024    4 S  0.0  0.2   3:57.48 php

Those hundredths haven't changed since I've looked at it. So my conclusion is that it's doing ... almost nothing, at the very most.

$ ls -ld /proc/10766/
dr-xr-xr-x 7 root root 0 2016-03-09 08:55 /proc/10766/

tells me it's been going for some time; server time is now:

$ date
Wed Mar  9 11:08:29 GMT 2016

The last line of the php script writes to a log file, and that line is present in the log file. Execution of the php script is the final thing in the shell script.

How do I go about diagnosing why this process hasn't quit?


Here's an edited version of the shell script I'm running:


DATE=$(date +%Y-%m-%d)

  • You could attach to it using strace -p 10766 to see what it's actually doing. – Mugurel Mar 9 '16 at 11:18
  • @Mugurel I see read(4, . There isn't a file named 4 in /proc/self/fd - is that (part of) the problem? – Bobby Jack Mar 9 '16 at 11:25
  • could you include the command line you are using to launch php? or better a chunk of your shell script – pete Mar 9 '16 at 12:23
  • @pete I've added the shell script to my original question (I don't think I can have that properly formatted in a comment). Note that paths are not real. – Bobby Jack Mar 9 '16 at 12:45
  • 1
    @BobbyJack, you should check /proc/10766/fd/4. PHP process seems to wait for an input data that may come from a file, pipe, socket or another file descriptor. `/proc/self/fd' shows file descriptors created by your shell instead. – Anderson Medeiros Gomes Mar 9 '16 at 12:54

The process is listed as 'sleeping' not finished or zombied.

10766 root      20   0 40640 6024    4 S  0.0  0.2   3:57.48 php

Its stuck doing something, given you said it had read(4, ... in a strace output I'd say its probably waiting for the other end of a socket connection send it data. Like a website has given up sending you data.

Thats a total guess though.

There almost certainly should be a file descriptor for 4 which gives more information if you try lsof -p10756 and see what its up to.

  • Thanks. Your diagnosis is pretty much spot on. Is that process ever going to give up, or should I kill it? – Bobby Jack Mar 9 '16 at 13:21
  • If its a website on the other end, I suspect you are never going to get a response at this point. – Matthew Ife Mar 9 '16 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.