Edit Logrotate: Reduce Complexity & hard set 100M size limit (#4038)

* simplify logrotate and force hard size limit
* default log rotation in build sd card & 100M limit
* changing to size limit for tor logs
* changing to size limit for CLN logs
* force a log rotate on every boot
This commit is contained in:
/rootzoll 2023-07-31 22:08:16 +02:00 committed by GitHub
parent 0d0e5581a5
commit 9bfc8237e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 53 deletions

View file

@ -491,55 +491,25 @@ fi
sed -i "s/^#SystemMaxUse=.*/SystemMaxUse=250M/g" /etc/systemd/journald.conf
sed -i "s/^#SystemMaxFileSize=.*/SystemMaxFileSize=50M/g" /etc/systemd/journald.conf
# change log rotates
# see https://github.com/rootzoll/raspiblitz/issues/394#issuecomment-471535483
## LOG ROTATION
# GLOBAL for all logs: /etc/logrotate.conf
echo "# Optimizing log files: rotate daily max 100M, keep 4 days & compress old"
sed -i "s/^weekly/daily size 100M/g" /etc/logrotate.conf
sed -i "s/^#compress/compress/g" /etc/logrotate.conf
# SPECIAL FOR SYSLOG: /etc/logrotate.d/rsyslog
# to test config run: sudo logrotate -v /etc/logrotate.d/rsyslog
rm /etc/logrotate.d/rsyslog 2>/dev/null
echo "
/var/log/syslog
{
rotate 7
daily
missingok
notifempty
delaycompress
compress
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
}
/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
{
rotate 4
size=100M
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
}
/var/log/kern.log
/var/log/auth.log
{
rotate 4
size=100M
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
}
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
@ -547,19 +517,19 @@ echo "
/var/log/messages
{
rotate 4
weekly
size 100M
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
invoke-rc.d rsyslog rotate > /dev/null
service logrotate restart
endscript
}
" | tee ./rsyslog
mv ./rsyslog /etc/logrotate.d/rsyslog
chown root:root /etc/logrotate.d/rsyslog
service logrotate restart
service rsyslog restart
echo -e "\n*** ADDING MAIN USER admin ***"

View file

@ -167,6 +167,9 @@ sleep 5
# CLEANING BOOT SYSTEM
################################
# force a rotation of every log on boot
logrotate -f /etc/logrotate.d/rsyslog
# Emergency cleaning logs when over 1GB (to prevent SD card filling up)
# see https://github.com/rootzoll/raspiblitz/issues/418#issuecomment-472180944
echo "*** Checking Log Size ***"

View file

@ -52,12 +52,6 @@ echo "### BASIC SYSTEM SETTINGS ###" >> ${logFile}
echo "# Make sure the user bitcoin is in the debian-tor group"
usermod -a -G debian-tor bitcoin
echo "# Optimizing log files: rotate daily, keep 1 week & compress old days " >> ${logFile}
sed -i "s/^weekly/daily/g" /etc/logrotate.conf >> ${logFile} 2>&1
sed -i "s/^rotate 4/rotate 7/g" /etc/logrotate.conf >> ${logFile} 2>&1
sed -i "s/^#compress/compress/g" /etc/logrotate.conf >> ${logFile} 2>&1
systemctl restart logrotate
# make sure to have bitcoin core >=22 is backwards comp
# see https://github.com/rootzoll/raspiblitz/issues/2546
sed -i '/^deprecatedrpc=.*/d' /mnt/hdd/bitcoin/bitcoin.conf 2>/dev/null

View file

@ -322,8 +322,8 @@ always-use-proxy=true
echo "\
/home/bitcoin/.lightning/${CLNETWORK}/cl.log
{
rotate 5
daily
rotate 4
size 100M
copytruncate
missingok
olddir /home/bitcoin/.lightning/${CLNETWORK}/cl.log_old

View file

@ -136,8 +136,8 @@ case "$1" in
# add logrotate config for modified Tor dir on ext. disk
sudo tee /etc/logrotate.d/raspiblitz-tor >/dev/null <<EOF
/mnt/hdd/tor/*log {
daily
rotate 5
size 100M
rotate 4
compress
delaycompress
missingok