Linux memory release script

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.