Actions

 Langue:
 Flux RSS:

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