ตัวอย่าง Code PHP Grab Process ID จาก Linux Sever

By | 07/04/2018
Spread the love

[cc lang=”php”]
function isRunning($dm) {
$cmd = “ps o pid,command -C php”;
$res = shell_exec($cmd);
$expl = array();
/*
$res=trim(” PID COMMAND
21682 /usr/local/bin/php -f program.php key1
23380 /usr/local/bin/php -f program.php key2
23473 /usr/local/bin/php -f program.php key3″);
*/
$expl = explode(“\n”,$res);
foreach ($expl as $pss) {
/*
echo ‘

';
		print_r($expl = explode(" ",$pss);
		echo '

‘;
*/
$expl = explode(” “,trim($pss));
if($expl[4]==$dm) {
$return = trim($expl[0]);
}
}
if($return == “”) {
$return = “off”;
}
return $return;
}
[/cc]

ใส่ความเห็น