Why doesn't exec(“top”); work on Linux?

后端 未结 5 1204
醉酒成梦
醉酒成梦 2020-12-21 09:54

I was trying to execute this command

echo exec(\"top\");

and

echo exec(\"/usr/bin/top\");

neither works

5条回答
  •  抹茶落季
    2020-12-21 10:01

    I used:

    $cpu = preg_split('/[\s]+/', shell_exec('mpstat 1 1'));
    $cpu = 100-$cpu[42];
    

    100% minus the idle time.

提交回复
热议问题