Implement shell script sharing _linux shell for freeing CentOS system memory

Source: Internet
Author: User

These days found that CentOS system memory has been up, even if the Apache and MySQL closed, memory is not released, you can use the following script to free memory:

Script content:

Copy Code code as follows:

#! /bin/bash
# Cache Release:
# to free Pagecache:
Sync
Sync
#echo 1 >/proc/sys/vm/drop_caches
# to-free dentries and inodes:
#echo 2 >/proc/sys/vm/drop_caches
# to free Pagecache, dentries and Inodes:
Echo 3 >/proc/sys/vm/drop_caches

Use System crontab to achieve automatic daily operation:

Copy Code code as follows:

Crontab-e


Enter the following content:


Copy Code code as follows:

* * * */root/cached.sh


Free memory at 0 per day, which can be modified to suit your needs.

If you are prompted for an error when running./cached.sh: Permission denied permissions, you can run:

Copy Code code as follows:

chmod +x. cached.sh


In addition, you can modify the/etc/sysctl.conf method to achieve the purpose of automatically releasing the cache. But not enough memory, it is best to look for other reasons, such as whether the program settings are reasonable, whether the burst traffic is very large, or the program is not reasonable to cause memory overflow, after all, the operating system itself design will consider all aspects of the problem, forced to vacate the size of the cache, may just put the problem to the temporary It is not conducive to judging the problem.

Related Article

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.