0

All my users in /home/{user}/ have a specific error_log file in it that may grow overtime.

So I was thinking about using logrotate to implement some kind of file reducing on it : when the file reaches 500kb, we remove the first lines to reduce it to lower than 500kb.

It's not important to keep what is removed, so keeping the old lines is not necessary.

I took a look at logrotate, and I came to this configuration file, but since I'm new with LogRotate, I was wondering if it would work.

/home/*/error_log {
    daily
    size 500k
    rotate 0
    notifempty
    missingok
    copytruncate
}

Thanks for your help :)

Cyril N.
  • 624
  • 1
  • 10
  • 36

1 Answers1

0

Ok I found it, and it seems to work :)

/home/*/error_log {
    daily
    size 500k
    rotate 1
    notifempty
    missingok
    copytruncate
    nocreate
    postrotate
        tail -n 50 error_log.1 > error_log
        rm -f error_log.1
    endscript
}
Cyril N.
  • 624
  • 1
  • 10
  • 36