From 253e705fc6f46505fcf8e5205473a18389b90803 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Thu, 21 Sep 2023 10:38:53 +0000 Subject: [PATCH] Delete log files older than 5 days #87 --- universal/functions.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/universal/functions.bash b/universal/functions.bash index ea18d12..1203506 100644 --- a/universal/functions.bash +++ b/universal/functions.bash @@ -5,6 +5,10 @@ log () { logfileSetup () { logFileName="$scriptName-$(date +"%Y_%m_%d_%I_%M_%p").txt" + + # delete log files older than 5 days + find "/config/logs" -type f -iname "$scriptName-*.txt" -mtime +5 -delete + if [ ! -f "/config/logs/$logFileName" ]; then echo "" > "/config/logs/$logFileName" chmod 666 "/config/logs/$logFileName"