我在我的linux服务器(Ubuntu)中运行命令.例如:
screen -A -h 1500 -m -dmS test_command_one /home/SKY-users/SKY-001/./script
Run Code Online (Sandbox Code Playgroud)
这个后台进度的PID是否有任何方法,屏幕名称是:test_command_one?
ps aux | grep test_command_one:
root 6573 8.1 2.4 271688 123804 pts/4 Ss+ Oct19 3:04 /home/SKY-users/SKY-001/./ ...
Run Code Online (Sandbox Code Playgroud)
我想回到这个PID: 6573
PHP :(简单)
<?php
$output = shell_exec('sudo ps aux | grep test_command_one');
$array = explode("\n", $output);
echo '<pre>'.print_r($array, true).'</pre>';
?>
Run Code Online (Sandbox Code Playgroud)
感谢帮助!
rom*_*nsh 15
编辑:
通过与@WagnerVaz的代码结合
$mystring = "test_command_one";
exec("ps aux | grep 'screen .* $mystring' | grep -v grep | awk '{ print $2 }' | head -1", $out);
print "The PID is: " . $out[0];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12593 次 |
| 最近记录: |