一、需求背景
Linux默认top或者ps命令,查看出来占用情况显示单位不友好、不易懂。
二、命令参数
1、 以MB为单位显示
ps aux --sort=-%mem | awk '{print $6/1024 " MB", $11}' | head -n 11
2、 以MB为单位显示,同时显示进程ID
ps aux --sort=-%mem | awk '{print $2, $6/1024 " MB", $11}' | head -n 11
PID 0 MB COMMAND
2390 301.926 MB java
2887 120.707 MB /opt/py3/bin/python3.6
2842 119 MB /opt/py3/bin/python3.6
2873 117.539 MB /opt/py3/bin/python3.6
2118 117.258 MB mysqld
2843 115.965 MB /opt/py3/bin/python3.6
2504 44.9688 MB /app/gogs/gogs
1221 40.5703 MB /usr/bin/dockerd
1022 20.9922 MB /usr/bin/containerd
1952 17.1953 MB /bin/drone-server
3、htop命令
[
已加载插件:fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 7.0 kB 00:00:00
* base: mirrors.aliyun.com
* epel: mirror.lzu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:01
(2/2): epel/x86_64/primary_db | 7.0 MB 00:00:01
正在解决依赖关系
--> 正在检查事务
---> 软件包 htop.x86_64.0.2.2.0-3.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================================================
Package 架构 版本 源 大小
================================================================================================================
正在安装:
htop x86_64 2.2.0-3.el7 epel 103 k
事务概要
================================================================================================================
安装 1 软件包
总下载量:103 k
安装大小:218 k
Downloading packages:
htop-2.2.0-3.el7.x86_64.rpm | 103 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : htop-2.2.0-3.el7.x86_64 1/1
验证中 : htop-2.2.0-3.el7.x86_64 1/1
已安装:
htop.x86_64 0:2.2.0-3.el7
完毕!