Debian: Find out CPU usage using bash(Debian:使用 bash 找出 CPU 使用率)
问题描述
我正在使用 PHP 来读取当前的 CPU 使用率.我在 vServer 上,所以 shell_exec 已启用.
I'm using PHP to read the current CPU usage. I'm on a vServer, so shell_exec is enabled.
我在 ps
上尝试过 grep
,但没有成功.如何使用 bash 读取当前的 % CPU 使用率?
I have tried grep
on ps
, but it didn't work.
How can I read the current % CPU usage using bash?
推荐答案
最简单的方法就是使用 sys_getloadavg
The easiest way is simply to use sys_getloadavg
如果要直接询问操作系统,请使用 uptime
If you want to directly ask the OS, use uptime
$uptimeString = `uptime`;
或任何现有答案 如何在 bash 中做完全相同的事情并用反引号括起来.
Or any of the existing answers to how to do exactly the same thing in bash and just wrap in backticks.
这篇关于Debian:使用 bash 找出 CPU 使用率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Debian:使用 bash 找出 CPU 使用率


基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01