1、查看系统内存占用
free -m
[root@localhost ~]# free -m total used free shared buffers cached Mem: 2004 573 1431 0 47 201 -/+ buffers/cache: 323 1680 Swap: 1983 0 1983
2、指定时间间隔,不间断的监控内存
free -m -s 5 #每5秒显示一次
[root@localhost ~]# free -m -s 5 total used free shared buffers cached Mem: 2004 571 1433 0 47 202 -/+ buffers/cache: 321 1683 Swap: 1983 0 1983 total used free shared buffers cached Mem: 2004 571 1433 0 47 202 -/+ buffers/cache: 321 1683 Swap: 1983 0 1983
3、自动每隔一段时间,监控内存(和2的区别在于在同一条记录上刷新显示,2为追加显示)
watch -n 3 -d free
[root@localhost ~]# watch -n 3 -d free Every 3.0s: free Tue Oct 29 03:05:43 2019 total used free shared buffers cached Mem: 2052988 586504 1466484 0 49184 207360 -/+ buffers/cache: 329960 1723028 Swap: 2031608 0 2031608
参考文章: