centos 釋放內容

似懂非懂视为不懂發表於2024-12-10
#!/bin/bash
used=`free -m | awk 'NR==2' | awk '{print $3}'`
free=`free -m | awk 'NR==2' | awk '{print $4}'`
echo "===========================" >> /tmp/mem.log
date >> /tmp/mem.log
echo "Memory usage before | [Use:${used}MB][Free:${free}MB]" >> /tmp/mem.log
sync && echo 1 > /proc/sys/vm/drop_caches
sync && echo 2 > /proc/sys/vm/drop_caches
sync && echo 3 > /proc/sys/vm/drop_caches
used_ok=`free -m | awk 'NR==2' | awk '{print $3}'`
free_ok=`free -m | awk 'NR==2' | awk '{print $4}'`
echo "Memory usage after | [Use:${used_ok}MB][Free:${free_ok}MB]" >> /tmp/mem.log
echo "OK" >> /tmp/mem.log
echo "===========================" >> /tmp/mem.log
echo "clean yum cache" >> /tmp/mem.log
yum clean all >> /tmp/mem.log

相關文章