You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
561 B
Bash
22 lines
561 B
Bash
#!/bin/sh
|
|
# Script By Finch : Log_Rotate
|
|
|
|
TIME=`date +%c`
|
|
DIR=/home/bots/mrkayjaydee/portfolio/old-logs
|
|
|
|
# Création dossier "old-logs" si il n'existe pas
|
|
if [ ! -d "$DIR" ]; then
|
|
/bin/mkdir "$DIR"
|
|
/bin/chown bot:bot "$DIR"
|
|
fi
|
|
|
|
# Déplacement du fichier (si il existe) de log dans le dossier "old-logs"
|
|
if [ -f "./logs.txt" ]; then
|
|
/bin/cp ./logs.txt "$DIR/logs--$TIME.txt"
|
|
> logs.txt
|
|
fi
|
|
|
|
# Suppression des fichiers de logs vieux de 7 jours dans "old-logs"
|
|
if [ ! -z "$(ls -A $DIR)" ]; then
|
|
/bin/find $DIR/* -mtime +7 -exec /bin/rm {} \;
|
|
fi |