Here's my code(Laravel)
$process= new Symfony\Component\Process\Process("pgrep java");
try {
$process->mustRun();
} catch (ProcessFailedException $e) {
return $e->getMessage();
}
return $process->getOutput();
it fails. When I try pgrep --help
it succeeds. I tried this when java is running and not. This is the error:
I also use Docker by the way, and I've already tried: docker-compose exec workspace bash
and cd
to /var/www/laravel/public
and executed pgrep java
both when java is running and not. When java is running, as expected, it outputs the PID. pkill java
also doesn't work. I wonder why.