VI/root/software/freemem. Sh
#
##########################
# Freemem by Camor
##########################
#! /Bin/sh
Time1 = 'date + % Y % m % d'
Time2 = 'date + % K: % m: % s'
Mkdir/var/log/freemem
CD/var/log/freemem
#
# Echo ""> memstat _ $ time1.log
#
Echo $ time1 -- $ time2> memstat _ $ time1.log
Echo "------------------"> memstat _ $ time1.log
Echo "the mem stat is:"> memstat _ $ time1.log
Echo ""> memstat _ $ time1.log
Free> memstat _ $ time1.log
Echo ""> memstat _ $ time1.log
# Sync
Echo "... freeing..."> memstat _ $ time1.log
Echo ""> memstat _ $ time1.log
#
Echo 1>/proc/sys/Vm/drop_caches
Echo 2>/proc/sys/Vm/drop_caches
Echo 3>/proc/sys/Vm/drop_caches
Echo "---> OK! "> Memstat _ $ time1.log
Echo ""> memstat _ $ time1.log
Free> memstat _ $ time1.log
Echo "============================================== ====================================================== "> memstat _ $ time1.log
Echo ""> memstat _ $ time1.log
Echo ""> memstat _ $ time1.log
CD-
CAT/var/log/freemem/memstat _ $ time1.log
# Script end
Chmod 777/root/software/freemem. Sh
Note that it is best to edit the script with editplus, and then save the UTF-8 when saving another, do not save as UTF-8 + BOM form! Then upload it to centos through ssh!
Scheduled execution:
Echo "*/30 ***** root/software/freemem. Sh">/etc/crondtab