Quantcast
Viewing all articles
Browse latest Browse all 6168

Listing all running processes on server using PHP

I am trying to get a list of all processes currently running on my Ubuntu server using PHP. Ideally, I would like to get the following information:

  • The Process ID
  • The Command Used to Execute the Process
  • The Arguments Given to the Process

I know that I can use exec to call ps to list the currently running processes.

exec('ps aux', $output);

However, the output is formatted with arbitrary number of spaces, so parsing it is not the easiest thing in the world.

I could potentially use explode or preg_split to parse, but is there an easier way to get a list of all running processes using php, along with the process id, command, and arguments?


Viewing all articles
Browse latest Browse all 6168

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>