1

I am working with a pcie device, and corresponding pcie kernel driver. Let's call it pci_driver.c

pci_driver.c is full of printk messages similar to those:

printk(KERN_INFO "pcie_demo: :RD ADDR:   0x%08X\n",(virt_base+bulk_rw.start_addr));
printk(KERN_WARNING"pcie_demo: %s: Init: Device not enabled.\n", gDrvrName);

When I load the driver and run the application, I noticed that /var/log/syslog file size is growing rapidly to 20GB or more. I read in some of the questions that this indicates a problem, but actually my application is working smoothly, so I think that this is not a particular problem; instead, the kernel messages from printk are just stored in syslog file and accumulate very fast (as expected from pcie card).

For now, I clean the memory with this command once in a while:

truncate -s 0 /var/log/syslog

and delete the rotated files: syslog.*

I tried this approach: How do I limit the size of my syslog?

To limit the size of syslog, without much success.. syslog continue to grow without any limit.

What i'm interested in is a sustainable solution that will limit the size of syslog and other log files in /var/log. I prefer an in-system solution rather than a script that is running in the background.

Thanks a lot.

Jonathan
  • 21
  • 4

1 Answers1

0

Yes, your solution is not sustainable since you have to delete syslog all the time, first lets be sure that you use logrotate properly before trying other solutions:

In an editor in sudo mod go to /etc/logrotate.d/rsyslog

for example if we want to to rotate each 100MB It should look like this:

/var/log/syslog
{
    size 100M
    rotate 4
    compress
    missingok
    notifempty
    delaycompress
    postrotate
        /usr/lib/rsyslog/rsyslog-rotate
    endscript
}

we check that it is scheduled to run regulary, if not add it:

cat /etc/cron.daily/logrotate

then we test and it should work

sudo logrotate -f /etc/logrotate.conf
Saxtheowl
  • 2,394
  • 2
  • 12
  • 22