• 🏠 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 rename log files, and add the current date on the filename. In this example, if the current date is 2024/04/10, the file cacti.log will be renamed to cacti_20240410.log.

    rotate_logs.sh

    #!/bin/bash 
    ### Initialisation for environnement variables mandatory for DjeShellSteps ### 
    . `dirname $0`/djeshellsteps.sh 
    ### Beginning of Shell Script ### 
    BeginSteps 
    echo "Starting Shell Script..." 
    ### Step 10 - Rotating Cacti Log File ### 
    Step 10 "Rotating cacti Log file" 
    if [ $RunThisStep -eq 1 ]; then 
      cd $LogDir 
      mv cacti.log cacti.`date +%Y%m%d`.log 
    fi 
    ### End of Shell Script ### 
    EndSteps 

    Retour



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