Log rotation ensures that log files do not grow indefinitely, consuming all disk space. Below is a simple guide to set up log rotation for your Redbelly Node.
Open the configuration file for Redbelly logs:
sudo nano /etc/logrotate.d/rbbc_logsAdd the following configuration:
/var/log/redbelly/rbn_logs/rbbc_logs.log {
daily # Rotate logs daily
size 5G # Rotate if log file exceeds 5GB
rotate 10 # Keep last 10 rotated logs
copytruncate # Truncate the original log file after rotation
missingok # Ignore if the log file is missing
notifempty # Do not rotate if the log file is empty
compress # Compress rotated logs
delaycompress # Delay compression until the next rotation
create 0640 rbnuser rbnuser # Set ownership and permissions
}Save and close the file.
Run the following command to verify your setup:
sudo logrotate -f /etc/logrotate.d/rbbc_logsCheck if new rotated files (rbbc_logs.log.1, rbbc_logs.log.1.gz) have been created:
ls -lh /var/log/redbelly/rbn_logs/Log rotation typically runs daily via a systemd timer or cron job. Verify it:
sudo systemctl status logrotateCheck if logrotate is scheduled under /etc/cron.daily/logrotate.
Ensure logs arenβt consuming excessive disk space:
du -sh /var/log/redbelly/rbn_logs/Your Redbelly Node logs are now managed efficiently with log rotation. Logs will be compressed, archived, and space will be freed periodically.
Feel free to reach out for help or feedback! π