I'm very new to using SSH and am having trouble finding a way to view and kill PHP processes that are running.

When I say "PHP processes," I mean PHP files that were started through the browser, but that have continued to run when they were supposed to stop.

I tried this:

ps aux | grep php

But there aren't any results, even though I know the files are running.

How can I view the files that are running and then selectively kill them (or kill them all)?

2 Answers 2


Htop can be used to view processes and selectively kill them:

sudo apt-get install htop

As ckujau said, it depends on your setup, but typically a new php process is spawned by apache and lives for the duration of a request. In htop, inspect apache while making a request. A php process should start. If it stays alive, you can select and kill it.

Here's a screenshot of htop showing php-fpm processes. php-fpm maintains a pool of long running php processes, able to be reused for multiple requests.

Note 'htop' is a more user friendly version of 'top'.

See also htop explained: https://peteris.rocks/blog/htop/

enter image description here

  • How do you get it to just show php processes?
    – Nate
    Feb 23, 2014 at 4:26
  • Filter by pressing F4 or \ key and typing the text you want to filter by.
    – Mark
    Apr 1, 2014 at 22:07
  • 1
    Display as 'Tree' by pressing F5 or t. This shows the hierarchy of processes and forked child process. Sending a terminate signal to a process will usually also terminate it's child processes.
    – Mark
    Apr 1, 2014 at 22:14

The "php files", that is the program files ending in .php may not be visible with ps. But ps may be able to display the machinery that will in turn run those .php files. Depending on your setup this could be managed via fast-cgi or mod_php or even php-fpm. If you use mod_php, then there will be no "php processes" visible for ps. You can still see if your PHP engine is in use by using lsof:

$ lsof -ln

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.