• Uncategorized

About php : Get-list-of-running-processes-on-the-server-in-laravel-duplicate

Question Detail

I want to get list of running processes on the server with Laravel.

How can I do this?

Question Answer

all data you need to interact with simply lies in /proc folder of your operation system, keep that in mind that the contents of this folder are not such a real file system but also are some virtual files that keep a real-time system status.

if you want to read more about /proc you can refer to this page.

now all you need is to somehow read the contents of the file and gather all your desired data into whatever sink you want (databases/HTML page /cache or etc).

this can be done by PHP, read the file, explode by space and get results.

also if you want to just use Laravel you can use Symfony process class (that you have in Laravel illuminate)

Import the class into your file with use Symfony\Component\Process\Process;

Execute your command:

$process = new Process(['ps', '-aux']);
// executes after the command finishes
if (!$process->isSuccessful()) {
    throw new ProcessFailedException($process);
echo $process->getOutput();

if you have an issue with this read the Symfony documentation

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.