Issues with logrotate and Bitcoin Core logs

9 replies 67 views
shard_degenFull Member
Posts: 68 · Reputation: 298
#1Aug 26, 2021, 09:07 AM
Hey there. I've got Debian Bookworm running on a RockPro64 SBC and I'm using the Bitcoin Core RPC client version v25.0.0. My logrotate version is 3.21.0. Here’s the configuration I set up for the Bitcoin Core logrotate: But for some reason, my log files are around 1.5Gb each, even though I set them to be capped at 50Mb. For comparison, my Lightning Network logrotate config works just fine: Here are the Bitcoin Core log files: And these are the logs for my LN: So what could I be doing wrong?
5 Reply Quote Share
ryan_nodeSenior Member
Posts: 204 · Reputation: 859
#2Aug 26, 2021, 11:53 AM
It looks like it's only rotating the logs daily and not respecting maxsize. It just happens to be that your LN logs just happen to be around 50 MB when rotated daily. According to https://superuser.com/questions/1584101/why-logrotate-maxsize-condition-is-not-working, not all versions of logrotate have a maxsize option, so you should check the manpage of your install to make sure that it is indeed there.
2 Reply Quote Share
LuckyCoinLegendary
Posts: 832 · Reputation: 4795
#3Aug 26, 2021, 09:21 PM
Your Bitcoin Core log files are not accessible to group and world, only to your account. If you set up logrotate to run with some system account and not as root, you should set the permissions of the debug.log file to be 0644 so that the file can be copied. Also try running logrotate daemon as root and see if that works, if it does then it is definitely a file permissions error as I explained.
1 Reply Quote Share
shard_degenFull Member
Posts: 68 · Reputation: 298
#4Aug 26, 2021, 09:43 PM
I'm going to try size in my Bitcoin log file config and check tomorrow how are the log files. If it is that the case, then I'll also ave to change the same setting for my LN config file. When I run man logrotate I can see a maxsize option. But also in the manpage, where the examples are, they don't use this setting. They use size instead. But they mention minsize, size and maxsize But I'll try with size for a few days to see if anything changes! Edited 1; I also changed the permissions of log files of Bitcoin Core folder!
3 Reply Quote Share
shard_degenFull Member
Posts: 68 · Reputation: 298
#5Aug 27, 2021, 10:58 PM
Seems that at least from yesterday, mu log files increased even further of size. lol. So, I guess that the keyword size and/or max/minsize may not be the problem here! Permissions either because I changed permissions and there was no effect on the size of the files! I have now 2 files with aroun 2.5Gb big!
3 Reply Quote Share
shard_degenFull Member
Posts: 68 · Reputation: 298
#6Aug 28, 2021, 04:22 AM
I'm back to this as I have been told that Bitcoin Core won't work with Logrotate because it doesn't write any output to stdout, therefore systemd cannot know anything about it. Maybe my wording is not the most accurate, but I wanted to know if this is true, if anyone knows! Probably devs would know, no?
4 Reply Quote Share
ryan_nodeSenior Member
Posts: 204 · Reputation: 859
#7Aug 28, 2021, 06:44 AM
logrotate works fine with Bitcoin Core, you just need to send SIGHUP to it after rotating so that it starts writing a new log file. Just reading through the problem you were having last year, the issue is that logrotate is a one shot command, not a persistent daemon (not sure how I missed this the first time). When it runs, it checks whether the log file matches it's criteria for rotating and keeping old logs, and if it does, it will rotate the log files and do whatever. However, it does not sit there watching the specified files to see if they match, rather it requires something external to kick it off. This is usually done with a systemd timer which specifies how frequently it should be run. I would guess that it was running once per day, whereas you probably want it to run more frequently, like every hour. You'll need to find the logrotate.timer systemd unit file and modify it to start logrotate at the frequency that works with how quickly your log files grow. You can find where systemd unit files are located by using systemctl status, e.g. I have mine setup to rotate the log files every hour if they are bigger than 5 MB, and to save the old log files to my NAS. Here's what my whole config looks like: /etc/logrotate.d/bitcoin /home/ava/.bitcoin/finish-logrotate.sh is a script that sends the SIGHUB signal and moves the rotated log file to the NAS: /usr/lib/systemd/system/logrotate.timer is logrotate's systemd timer unit file:
0 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#8Aug 28, 2021, 11:54 AM
Just checking: you didn't give logrotate access to your wallet, right? My debug.log is 12 MB since last September, but I'm not doing anything else with it. Even if you rotate them more often, 1.5 or more GB per day is a lot! What do you use them for?
3 Reply Quote Share
shard_degenFull Member
Posts: 68 · Reputation: 298
#9Aug 28, 2021, 05:27 PM
The size was becuase I was using debug level. I'm not sure exactly what I would have to do to "give logrotate access to my wallet". Not even sure if you're asking that ironically or if we were actually supposed to! :p
2 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#10Aug 28, 2021, 11:27 PM
Usually, logrotate is used for system logs, which usually are stored in /var/log. Bitcoin Core's debug.log is (by default) stored inside your user directory. It's probably going to be okay, but I like to keep default OPSEC by not giving any program read-access to data it doesn't need. But now that I'm typing this, I'm wondering if logrotate doesn't use root-permissions by default anyway.
0 Reply Quote Share
?Reply
Sign in to reply to this topic

Related topics