Delete log files older than 5 days

#87
This commit is contained in:
RandomNinjaAtk 2023-09-21 10:38:53 +00:00 committed by GitHub
parent 8b5dd8ac74
commit 253e705fc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,10 @@ log () {
logfileSetup () { logfileSetup () {
logFileName="$scriptName-$(date +"%Y_%m_%d_%I_%M_%p").txt" 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 if [ ! -f "/config/logs/$logFileName" ]; then
echo "" > "/config/logs/$logFileName" echo "" > "/config/logs/$logFileName"
chmod 666 "/config/logs/$logFileName" chmod 666 "/config/logs/$logFileName"