Skip to content

Commit

Permalink
Merge pull request #22 from thin-edge/fix-rotate-log-files
Browse files Browse the repository at this point in the history
fix: include log files in log rotation
  • Loading branch information
reubenmiller authored Jul 15, 2024
2 parents fbcf4c5 + 48e860f commit 99b9e24
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bin/monit-tedge-reconnect
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ remove_old_files() {
if [ "$MAX_FILES" -gt 0 ]; then
# ls -t "$LOG_DIR"/*.tar.gz | tail +6 | xargs rm
find "$LOG_DIR" -name "tedge-debug-*.tar.gz" | tail +"$MAX_FILES" | xargs rm
find "$LOG_DIR" -name "tedge-debug-*.log" | tail +"$MAX_FILES" | xargs rm
fi

# Only keep files newer than x days (protect against an empty log dir)
MAX_DAYS="${MAX_DAYS:-30}"
if [ "$MAX_DAYS" -gt 0 ] && [ -n "$LOG_DIR" ]; then
find "$LOG_DIR" -name "tedge-debug-*.tar.gz" -mtime "$MAX_DAYS" -exec rm -f {} \; ||:
find "$LOG_DIR" -name "tedge-debug-*.log" -mtime "$MAX_DAYS" -exec rm -f {} \; ||:
fi
}

Expand Down

0 comments on commit 99b9e24

Please sign in to comment.