Linux的内存释放脚本

it2022-05-06  1

vi /root/software/freemem.sh

############################  Freemem by Camor###########################!/bin/shTime1=`date +%Y%m%d`Time2=`date +%k:%M:%S`mkdir /var/log/freememcd /var/log/freemem##echo "">memstat_$Time1.log#echo $Time1--$Time2 >>memstat_$Time1.logecho "------------------" >>memstat_$Time1.logecho "The mem stat is :" >>memstat_$Time1.logecho "" >>memstat_$Time1.logfree >>memstat_$Time1.logecho "" >>memstat_$Time1.log#syncecho "....Freeing......" >>memstat_$Time1.logecho "">>memstat_$Time1.log#echo 1 > /proc/sys/vm/drop_cachesecho 2 > /proc/sys/vm/drop_cachesecho 3 > /proc/sys/vm/drop_cachesecho "---> OK ! " >>memstat_$Time1.logecho "">>memstat_$Time1.logfree >>memstat_$Time1.logecho "=========================================================================">> memstat_$Time1.logecho "">>memstat_$Time1.logecho "">>memstat_$Time1.logcd -cat /var/log/freemem/memstat_$Time1.log# 脚本结束

chmod 777 /root/software/freemem.sh

注意脚本最好用EditPlus进行编辑,然后另存时选择UTF-8保存,千万不能保存成UTF-8+BOM形式!然后用ssh传到CentOS中!

 

定时执行的办法:echo "*/30 * * * * root /root/software/freemem.sh" >> /etc/crondtab

 

转载于:https://www.cnblogs.com/littlehb/archive/2012/02/10/2345173.html


最新回复(0)