• 🏠 Accueil
  • 🧰 Générateurs
  • 📰 Blog
  • 🔎 Rechercher
  • 📧 Contact
  • 📘 Livre d'or
  • 🗞️ News
  • 💰 Soutien
  • ℹ️ Info : Le site a été modernisé pour être plus lisible et compatible avec les smartphones. N'hésitez pas à me signaler tout bug via le formulaire de contact.

    Description

    This script will display the current memory usage (first step), optimize it, and display the result in the third step.

    clean_memory.sh

    #!/bin/bash 
    ########################################################### 
    # File: clean_memory.sh                                   # 
    # Author: Jerome DESMOULINS  djeshellstepsATdesmoulins.fr # 
    # Description:                                            # 
    #   Display current memory usage, optimize it, and        # 
    #   display the result on a third step                    # 
    ########################################################### 
    ### Calling DjeShellSteps ### 
    . `dirname $0`/djeshellsteps.sh 
    BeginSteps 
    ########################################################### 
    Step 10 "Display current memory usage" 
    ########################################################### 
    if [ $RunThisStep -eq 1 ]; then 
    free -m 
    fi 
    ########################################################### 
    Step 20 "Optimizing memory" 
    ########################################################### 
    if [ $RunThisStep -eq 1 ]; then 
    sync; echo 3 > /proc/sys/vm/drop_caches 
    fi 
    ########################################################### 
    Step 30 "Display memory usage after optimization" 
    ########################################################### 
    if [ $RunThisStep -eq 1 ]; then 
    free -m 
    fi 
    ### End of Shell Script ### 
    EndSteps 

    Warning: This script must be launched by root user.

    Retour



    (c) 2005-2025 Jérôme DESMOULINS
    Mentions légales