Skip to content

Commit 57b6d3e

Browse files
committed
Run the rotation every hour to minimize lost logs on pod restart
1 parent aeef397 commit 57b6d3e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crontab

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Run logrotate.sh daily at midnight
2-
0 0 * * * /app/logrotate.sh >> /var/log/cron.log 2>&1
3-
0 0 * * * echo "Hello World! I am working!" >> /var/log/cron.log 2>&1
2+
0 * * * * /app/logrotate.sh >> /var/log/cron.log 2>&1
3+
0 * * * * echo "Hello World! I am working!" >> /var/log/cron.log 2>&1

logrotate.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
echo "Running logrotate"
44

5-
# Create a temporary logrotate configuration file
5+
# Create a temporary logrotate configuration file that rotates hourly and keeps 168 ( 7 days ) rotated logs
66
cat <<EOF > /tmp/logrotate.conf
77
"$LOG_PATH" {
8-
daily
9-
rotate 31
8+
hourly
9+
rotate 168
1010
compress
1111
delaycompress
1212
postrotate

0 commit comments

Comments
 (0)