shell-003:用for循环统计内存使用量
shell-100主要是用于练习!
#!/bin/bash
# 统计内存的使用量(这里用ps统计)
# 第一步:不打印第一行,这里的sed ‘1d’ 去掉
for n in `ps aux |sed '1d'`
# 第二步:获取内存那一列的数值
# 第三步:最后用循环相加!
sum=
for n in `ps aux |sed '1d'|awk '{print $6}'`
do
sum=$[$sum+$n]
done
# 知识点:for循环,sum的函数相加!比如1-100的相加
# 简单的1-100的函数相加
sum=0
for n in ·seq 100·
do
sum=$[$sum+$n]
dons
echo $sum
[end]
shell-003:用for循环统计内存使用量的更多相关文章
- 《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #12 使用Memory Cgroup限制内存使用量
HACK #12 使用Memory Cgroup限制内存使用量 Memory Cgroup是Cgroup的资源限制功能之一,可以控制特定进程可以使用的内存量.Memory CgroupMemory C ...
- 利用shell监控cpu、磁盘、内存使用率
利用shell监控cpu.磁盘.内存使用率,达到警报阈值发邮件进行通知 并配合任务计划,即可及时获取报警信息 #!/bin/bash ################################# ...
- shell脚本中select循环语句用法
shell脚本中select循环语句 1. 脚本中select的语法格式 select VAR in LIST do command1 command2 ... ... commandN done s ...
- 通过redis-rdb-tools分析redis内存使用量
背景:生产上一台redis服务器,物理内存32G,几个项目都在用,经常不足一月内存就会耗尽,然后开始使用swap,当swap也用尽的时候,系统就宕机.redis配置也优化过几次,但未见成效.因此决定看 ...
- SQL Server 内存使用量下降问题
SQL server这个程序是非喜欢内存这东西的.所以它的内存使用量下降,一定是被别人给抢去了.这件事的后果就是SQL Server 变的 非常慢.怎么样才可以让这件事不太容易发生呢? ------- ...
- 网络分析shell脚本(实时流量+连接统计)
介绍一个强大的分析网络的shell脚本,此脚本是从EZHTTP拆分出来的,觉得有必要单独介绍下.脚本运行效果截图: 此脚本包含的功能有: 1.实时监控任意网卡的流量 2.统计10秒内平均流量 3.统计 ...
- Java内存使用量测试
JVM内存使用量测试测试各种不同的数据结构在JVM中的内存使用量 import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import java.lang. ...
- Linux查看内存使用量和交换区使用量
Linux查看内存使用量和交换区使用量 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ free -m total used free shared buffe ...
- shell脚本之for循环
shell脚本之for循环 author :headsen chen 2017-10-18 09:50:41 个人原创,转载请注明.否则依法追究法律责任 1,cat forloop ...
随机推荐
- AngularJS框架
http://www.runoob.com/angularjs/angularjs-intro.html
- java基础篇之HashMap
HashMap和C#中的Dictionary基本一样 键是唯一值 值可以是对象 循环HashMap的方式:一: 1,通过Set<T> st = hs.keySet()找到所有的key值集合 ...
- CentOS7 启动docker.service失败(code=exited, status=1/FAILURE)
启动报错 Job for docker.service failed because the control process exited with error code. See "sys ...
- 【HDU 6031]】 Innumerable Ancestors
题意 有一棵有n个结点的树,这里有m个询问,每个询问给出两个非空的结点集合A和B,有些结点可能同时在这两个集合当中.你需要从A和B中分别选择一个节点x和y(可以是同一个结点)你的目标是使LCA(x,y ...
- Java 计算两个日期相差的天数
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; impor ...
- ARCGIS空间叠加分析(转)
ARCGIS空间叠加分析 https://blog.csdn.net/gswwldp/article/details/66974465 (2)双击④处的Identity,打开Identity操作对话框 ...
- sudo apt install libreadline-dev Reading package lists... Error!
luo@luo-ThinkPad-W540:~$ luo@luo-ThinkPad-W540:~$ luo@luo-ThinkPad-W540:~$ luo@luo-ThinkPad-W540:~$ ...
- 724. Find Pivot Index 找到中轴下标
[抄题]: Given an array of integers nums, write a method that returns the "pivot" index of th ...
- 62-U型数字
https://nanti.jisuanke.com/t/20683 #include <iostream> using namespace std; int main(){ int ct ...
- 10.Execution failed with exit status: 3
错误信息: insert overwrite table t_mobile_mid_use_p_tmp4_rcf select '201411' as month_id, a.prov_id, a.c ...