linux swapoff命令详解
Linux系统下swapoff命令用于关闭系统交换区(swap area),下面是swapoff命令内容的具体内容:
1、swapoff命令简介:
Linux系统下swapoff命令用于关闭系统交换区(swap area),swapoff实际上为swapon的符号连接,可用来关闭系统的交换区。
2、语法:
swapoff [设备]
3、参数:
-a将/etc/fstab文件中所有设置为swap的设备关闭 ;
-h帮助信息;
-V版本信息 。
实例:
显示分区信息,输入命令:
# sfdisk -l //显示分区信息
Disk /dev/sda: 1305 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024
以上就是小编今天的分享了,希望可以帮助到大家。
linux系统什么情况下使用swap
Linux下精确定位使用swap的进程,网友:值得拥有
相信做过运维的朋友,一定碰到在linux系统中,有时候会使用swap交换分区,一旦应用使用了swap,那么性能就会直线下降,应用响应时间变成,过一会儿,应用不再使用swap,应用又自动恢复了。
当运维人员去定位到底是哪个应用使用swap交换分区时,又非常的困难,因为很少有日志会记录这个,从监控平台,能看到某个时间段,linux的swap交换分区有使用。
为了解决这个问题,下面给大家分享一个Linux下精确定位使用swap的进程的shell脚本,这个脚本可以放到crontab下,一分钟执行一次。
脚本内容如下所示[root@localhost ~]# cat swap.sh #!/bin/bash# Get current swap usage for all running processesfunction getswap {SUM=0OVERALL=0for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; doPID=`echo $DIR | cut -d / -f 3`PROGNAME=`ps -p $PID -o comm --no-headers`for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`dolet SUM=$SUM $SWAPdoneecho "PID=$PID - Swap used: $SUM - ($PROGNAME )"let OVERALL=$OVERALL $SUMSUM=0doneecho "Overall swap used: $OVERALL"}getswap输出结果[root@localhost ~]# ./swap.sh PID=1 - Swap used: 0 - (systemd )PID=2 - Swap used: 0 - (kthreadd )PID=4 - Swap used: 0 - (kworker/0:0H )PID=5 - Swap used: 0 - (kworker/u256:0 )PID=6 - Swap used: 0 - (ksoftirqd/0 )PID=7 - Swap used: 0 - (migration/0 )PID=8 - Swap used: 0 - (rcu_bh )PID=9 - Swap used: 0 - (rcu_sched )PID=10 - Swap used: 0 - (lru-add-drain )PID=11 - Swap used: 0 - (watchdog/0 )PID=13 - Swap used: 0 - (kdevtmpfs )PID=14 - Swap used: 0 - (netns )PID=15 - Swap used: 0 - (khungtaskd )PID=16 - Swap used: 0 - (writeback )PID=17 - Swap used: 0 - (kintegrityd )PID=18 - Swap used: 0 - (bioset )PID=19 - Swap used: 0 - (bioset )PID=20 - Swap used: 0 - (bioset )PID=21 - Swap used: 0 - (kblockd )PID=22 - Swap used: 0 - (md )PID=23 - Swap used: 0 - (edac-poller )Overall swap used: 0
如果觉得输出的结果太多,还可以过滤掉Swap used: 0的记录
[root@localhost ~]# cat swap.sh #!/bin/bash# Get current swap usage for all running processesfunction getswap {SUM=0OVERALL=0for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; doPID=`echo $DIR | cut -d / -f 3`PROGNAME=`ps -p $PID -o comm --no-headers`for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`dolet SUM=$SUM $SWAPdoneecho "PID=$PID - Swap used: $SUM - ($PROGNAME )"let OVERALL=$OVERALL $SUMSUM=0doneecho "Overall swap used: $OVERALL"}getswap|egrep -v "Swap used: 0"输出结果[root@localhost ~]# ./swap.sh Overall swap used: 0
- 02-03生活
槟榔是什么
- 11-12生活
蒜苗怎么腌制才能长期保管
- 12-29教育
完整工伤赔偿的协议书范文
- 07-05生活
怎么判断大米是发霉了
- 04-23生活
简爱作者是谁
- 02-15科技
文件扩展名有哪些
- 11-18教育
一头三尾全不买解一生肖
- 12-22科技
ocp认证考试内容
推荐
- 1衣服上的草汁怎么才能去141
- 2zsbd网络语什么意思484
- 3汽车抵押合同协议书模板365
- 4好听的宠物名字大全187
- 5我的世界末地传送门如何做301
- 6太阳系内4颗内行星分别是380