Skip to content

Commit 280757d

Browse files
committed
bugfixe and doc for log2ram
1 parent 0cceeb0 commit 280757d

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

1_Pi_Config.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ if [[ "$REPLY" =~ ^(yes|y|Y)$ ]]; then
115115
dpkg-reconfigure tzdata
116116
fi
117117

118-
if [[ ! -f /usr/local/bin/ram2disk ]]; then
118+
if [[ ! -f /usr/local/bin/log2ram ]]; then
119119
echo -n "Do you want to enable log2ram [y/N] "
120120
read
121121
if [[ "$REPLY" =~ ^(yes|y|Y)$ ]]; then
@@ -124,7 +124,18 @@ if [[ ! -f /usr/local/bin/ram2disk ]]; then
124124
cd log2ram
125125
chmod +x install.sh uninstall.sh
126126
./install.sh
127-
ln -s /usr/local/bin/ram2disk /etc/cron.hourly/
127+
ln -s /usr/local/bin/log2ram /etc/cron.hourly/
128+
echo "cleaning up log rotation"
129+
replace /etc/logrotage.d/rsyslog "^.*daily.*$" " hourly"
130+
replace /etc/logrotage.d/rsyslog "^.*monthly.*$" " daily"
131+
replace /etc/logrotage.d/rsyslog "^.*delaycompress.*$" " "
132+
133+
echo "forcing one log rotation"
134+
logrotate /etc/logrotate.conf
135+
echo "Please don't forget to adjust the logrotate"
136+
echo "paratemeters in /etc/logrotage.d/* to avoid"
137+
echo "filling up the ramdisk, see README in"
138+
echo "https://github.com/ch2i/LoraGW-Setup/"
128139
echo ""
129140
fi
130141
fi

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,59 @@ sudo systemctl stop loragw
293293
sudo systemctl start loragw
294294
```
295295

296+
## Adjust log2ram
297+
298+
if you chose log2ram to reduce SD card write, you need to change some log file rotation to avoid RAM Disk to be full.
299+
300+
For this you need to edit each file in `/etc/logrotate.d/`, and on each file:
301+
302+
- remove line(s) containing `delaycompress` (this avoid uncompressed old log)
303+
- change line(s) containing `rotate n` by rotate 12 (this this the max log file history)
304+
- change line(s) containing `daily` by `hourly` (rotate log each hour)
305+
- change line(s) containing `monthly` by `daily` (rotate log each day)
306+
307+
In this case we got last 12H with 1 file per hour. Of course, you can adjust these paramaters to feet you need, it's just an example,
308+
309+
file `/etc/logrotate.d/rsyslog`
310+
311+
```
312+
/var/log/syslog
313+
{
314+
rotate 12
315+
hourly
316+
missingok
317+
notifempty
318+
compress
319+
postrotate
320+
invoke-rc.d rsyslog rotate > /dev/null
321+
endscript
322+
}
323+
324+
/var/log/mail.info
325+
/var/log/mail.warn
326+
/var/log/mail.err
327+
/var/log/mail.log
328+
/var/log/daemon.log
329+
/var/log/kern.log
330+
/var/log/auth.log
331+
/var/log/user.log
332+
/var/log/lpr.log
333+
/var/log/cron.log
334+
/var/log/debug
335+
/var/log/messages
336+
{
337+
rotate 12
338+
hourly
339+
missingok
340+
notifempty
341+
compress
342+
sharedscripts
343+
postrotate
344+
invoke-rc.d rsyslog rotate > /dev/null
345+
endscript
346+
}
347+
348+
```
296349

297350
# And here is the final result
298351

0 commit comments

Comments
 (0)