Created
November 21, 2023 21:26
-
-
Save shadyrudy/9126bdb3dca844b462134daf381b97ec to your computer and use it in GitHub Desktop.
The logroate.d entry for pgbouncer. Rotates the log once a day.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/logrotate.d/pgbouncer | |
/var/log/postgresql/pgbouncer.log { | |
daily | |
missingok | |
rotate 7 | |
compress | |
delaycompress | |
notifempty | |
create 640 postgres adm | |
sharedscripts | |
postrotate | |
/usr/bin/pgrep -x pgbouncer > /dev/null && /usr/sbin/pgbouncer -R /var/run/postgresql/pgbouncer.pid | |
endscript | |
} | |
# Rotate pgbouncer logs. | |
# Log rotate settings details: | |
# Logfile location /var/log/postgresql/pgbouncer.log or /var/log/pgbouncer/pgbouncer.log | |
# daily: Rotate the log file daily. | |
# missingok: Do not output an error if the log file is missing. | |
# rotate 7: Keep the last 7 rotated logs. | |
# compress: Compress the rotated files. | |
# delaycompress: Delay compression of the rotated file to the next rotation cycle. This is useful in combination with compress. | |
# notifempty: Do not rotate the log if it is empty. | |
# create 640 postgres adm: Create a new log file with set permissions, owner, and group after rotation. | |
# sharedscripts: Run the postrotate script only once, not for each log file rotated. | |
# postrotate/endscript: Commands inside this block are executed after the log file is rotated. Here, | |
# it checks if PgBouncer is running | |
# (pgrep -x pgbouncer) | |
# and sends a signal to reopen its log files | |
# (/usr/sbin/pgbouncer -R or /usr/bin/pgbouncer -R depending on your install). | |
# The path /var/run/postgresql/pgbouncer.pid should be replaced with the actual path | |
# to your PgBouncer PID file if it's different, such as /var/run/pgbouncer/pgbouncer.pid | |
# Manually rotate via the command | |
# sudo logrotate -d /etc/logrotate.d/pgbouncer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment