Skip to content

Commit

Permalink
Merge pull request #427 from gechiang/202205
Browse files Browse the repository at this point in the history
[logrotate]: Separated sort and head commands to prevent broken pipe …
  • Loading branch information
gechiang authored Jul 27, 2024
2 parents 041d03a + 34dffde commit 43ccabd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion files/image_config/logrotate/rsyslog.j2
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
if [ $USED_KB -lt $THRESHOLD_KB ]; then
break
else
OLDEST_ARCHIVE_FILE=$(find /var/log -type f -printf '%T+ %p\n' | grep -E '.+\.[0-9]+(\.gz)?$' | sort | head -n 1 | awk '{ print $2; }')
OLDEST_ARCHIVE_FILE=$(find /var/log -type f -printf '%T+ %p\n' | grep -E '.+\.[0-9]+(\.gz)?$' | sort | awk 'NR == 1 {print $2}')

if [ -z "$OLDEST_ARCHIVE_FILE" ]; then
logger -p syslog.err -t "logrotate" "No archive file to delete -- potential for filling up /var/log partition!"
Expand Down

0 comments on commit 43ccabd

Please sign in to comment.