PHP code example of nabeghe / process-finger
1. Go to this page and download the library: Download nabeghe/process-finger library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nabeghe / process-finger example snippets
use Nabeghe\ProcessFinger;
// Get current PID
$pid = Process::getId();
// Check if a process exists
$exists = Process::exists($pid);
// Kill a process
Process::kill($pid, true);
// Restart a process
$newPid = Process::restart($pid, 'php script.php');
// Get memory usage
$memory = Process::getMemoryUsage($pid);
// Get CPU usage
$cpu = Process::getCpuUsage($pid);
// Get process environment (Unix only)
$env = Process::getProcessEnv($pid);
// List child processes
$children = Process::listChildren($pid);
// Get process name
$name = Process::getProcessName($pid);
// Check if running as root/admin
$isRoot = Process::isRunningAsRoot();
// Check if process is zombie
$isZombie = Process::isZombie($pid);
// Wait for process to exit
Process::wait($pid, 5); // Wait up to 5 seconds