一、需求背景
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
[root@Devlops ~]# ps aux --sort=-%mem | awk '{print $2, $6/1024 " MB", $11}' | head -n 11PID 0 MB COMMAND2390 301.926 MB java2887 120.707 MB opt/py3/bin/python3.62842 119 MB opt/py3/bin/python3.62873 117.539 MB opt/py3/bin/python3.62118 117.258 MB mysqld2843 115.965 MB opt/py3/bin/python3.62504 44.9688 MB app/gogs/gogs1221 40.5703 MB usr/bin/dockerd1022 20.9922 MB usr/bin/containerd1952 17.1953 MB bin/drone-server
3、htop命令

[root@Devlops ~]# yum -y install htop已加载插件:fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfileepel/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.combase | 3.6 kB 00:00:00docker-ce-stable | 3.5 kB 00:00:00epel | 4.7 kB 00:00:00extras | 2.9 kB 00:00:00updates | 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 kDownloading packages:htop-2.2.0-3.el7.x86_64.rpm | 103 kB 00:00:00Running transaction checkRunning transaction testTransaction test succeededRunning 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完毕!
文章转载自巴韭特锁螺丝,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




