SBC logrotate

Status
Not open for further replies.

Zol

Customer
Advanced Certified
Joined
Oct 31, 2018
Messages
52
Reaction score
13
Hey Community,

I have recently installed my first SBC 16.0.386 (Raspberry Pi 3B+) and I setup the Logging & Troubleshooting as follows:

12398

I would like to logrotate /var/log/3cxsbc/3cxsbc.log with compression.
Am I allowed to create a conf file under /etc/logrotate.d/ or could I ruin something?

Thanks,
Zol
 
Hey Community,

I have recently installed my first SBC 16.0.386 (Raspberry Pi 3B+) and I setup the Logging & Troubleshooting as follows:

View attachment 12398

I would like to logrotate /var/log/3cxsbc/3cxsbc.log with compression.
Am I allowed to create a conf file under /etc/logrotate.d/ or could I ruin something?

Thanks,
Zol
I strongly recommend you keep logging to Low on a Pi. It's IO intensive and an SDcard isn't the best IO performance.
 
You're right @Frederick Marcoux, thanks for the tip.
However I only connected 2 IP phones to the SBC for test purposes, so I'm not logging much (100MB per day so far).

Regardless the I/O permormance, I would like to keep at least 7 days of logs, without having to read the log from a 4GB logfile, hence my question about logrotate.
 
You're right @Frederick Marcoux, thanks for the tip.
However I only connected 2 IP phones to the SBC for test purposes, so I'm not logging much (100MB per day so far).

Regardless the I/O permormance, I would like to keep at least 7 days of logs, without having to read the log from a 4GB logfile, hence my question about logrotate.
The SBC should rotate it's own log but not by days, by size. That's why we select "Log Size: 100MB".

As for IO, number of phones don't matter, just leave the log as Low unless explicitly required by 3CX Support to gather verbose logs.
 
Updating the thread.

I created a new conf file in /etc/logrotate.d/

$ sudo vim 3cxsbc
Code:
/var/log/3cxsbc/3cxsbc.log {
    daily
    rotate 7
    compress
    copytruncate
    create 0644 tcxsbc tcxsbc
    dateext
    maxage 10
    missingok
}
Then I renamed the file /etc/cron.daily/logrotate to logrotate.old and created a new logrotate file:

$ sudo mv /etc/cron.daily/logrotate /etc/cron.daily/logrotate/logrotate.old
$ sudo vim /etc/cron.daily/logrotate
Code:
#!/bin/sh

/usr/sbin/logrotate -s /var/lib/logrotate/status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
        /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
I modified the permissions for the file to executable:

$ sudo chmod +x /etc/cron.daily/logrotate

The first time logfiles should be manually rotated with the following command:

$ /usr/sbin/logrotate -s /var/lib/logrotate/status /etc/logrotate.conf

The result after a few days is:
Code:
$ ls -lrth /var/log/3cxsbc/
total 34M
-rw-r--r-- 1 tcxsbc tcxsbc 7.3M Sep 26 01:27 3cxsbc.log-20190926.gz
-rw-r--r-- 1 tcxsbc tcxsbc 5.4K Sep 26 06:24 3cxsbc.log.mon
-rw-r--r-- 1 tcxsbc tcxsbc 8.8M Sep 27 13:18 3cxsbc.log-20190927.gz
-rw-r--r-- 1 tcxsbc tcxsbc 4.2M Sep 28 06:25 3cxsbc.log-20190928.gz
-rw-r--r-- 1 tcxsbc tcxsbc 6.0M Sep 29 06:25 3cxsbc.log-20190929.gz
-rw-r--r-- 1 tcxsbc tcxsbc 5.9M Sep 30 06:25 3cxsbc.log-20190930.gz
-rw-r--r-- 1 tcxsbc tcxsbc 1.3M Sep 30 06:42 3cxsbc.log
Note: in order to use vim you need to install it first, otherwise use nano

This thread can be closed as resolved.
 
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
111,933
Messages
589,817
Members
164,810
Latest member
astrobalaji