Summer's Blog
😈酷炫主页
✨运维
🎉安装
👀踩坑
  • k8s
  • shell
  • python
  • redis
  • elasticsearch
  • mysql
  • ceph
  • spark
  • 关于
  • 思维
  • 命令
  • 友链
  • 分类
  • 标签
  • 归档
👨‍👩‍👦‍👦腾讯云社区
🗣GitHub

Summer———夏苏文

💨运维界的前行者
😈酷炫主页
✨运维
🎉安装
👀踩坑
  • k8s
  • shell
  • python
  • redis
  • elasticsearch
  • mysql
  • ceph
  • spark
  • 关于
  • 思维
  • 命令
  • 友链
  • 分类
  • 标签
  • 归档
👨‍👩‍👦‍👦腾讯云社区
🗣GitHub
  • K8s

  • shell

    • 自动重启应用脚本
    • 自动重启docker脚本
    • 安装java脚本
    • 安装mysql脚本
    • 安装elasticsearch脚本
    • 安装redis脚本
    • 清理docker日志脚本
    • 钉钉报警脚本
    • 彩色进度条脚本
    • 奇数行和偶数行合并
    • 备份mysql脚本
    • cpu硬盘报警脚本
    • 安装node-exporter脚本
    • 批量ping探测网段ip
    • 一键安装VNC脚本
    • ssh免密登录脚本
    • 创建10个文件并写入内容
    • 模拟linux内存占用脚本
  • spark

  • Python

  • Redis

  • ceph

  • Elasticsearch

  • Mysql

  • 学习
  • shell
summer
2022-03-17

模拟linux内存占用脚本

#!/bin/bash
################################################################
#       Mem Used Script
#       eg. ./mem.sh 10G & to start testing
#       eg. ./mem.sh stop  to stop testing and clear env
#       update: 2020-04-21  charseki
################################################################
num=$1
user=`whoami`
 
start()
{
if [ -d /tmp/memory ];then
        echo "the dir "/tmp/memory" is already exist!, use it." >> mem.log
else
        sudo mkdir /tmp/memory
        mount -t tmpfs -o size=$num tmpfs /tmp/memory
fi
dd if=/dev/zero of=/tmp/memory/block >> mem.log 2>&1
}
 
stop()
{
 
rm -rf /tmp/memory/block
umount /tmp/memory
rmdir /tmp/memory
if [ -d /tmp/memory ];then
        echo "Do not remove the dir \"/tmp/memory\", please check "
else
        echo "clear env is done!"
fi
}
main()
{
if [ $num == 'stop' ];then
        stop
elif [ $user != "root" ];then
        echo "please use the \"root\" excute script!"
        exit 1
else
        start
fi
}
 
if [ $# = 2 -o $# = 1 ];then
        main
else
        echo 'Usage: <./mem.sh 10G &> to start  or <./mem.sh stop>  to clear env'
fi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#shell
上次更新: 2/17/2023, 5:59:37 PM
创建10个文件并写入内容
spark笔记

← 创建10个文件并写入内容 spark笔记→

最近更新
01
ceph块设备使用iscsi
03-29
02
Citrix设置vm开机自启动
02-17
03
ntp与chrony时间同步
12-17
更多文章>
Theme by Vdoing | Copyright © 2019-2023 夏苏文 | MIT License

网站已在灾难中运行:

蜀ICP备2022029853号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式