Logrotate replace log file with a binary one

20 Views Asked by At

One of my project is logging in a simple file. This file may grow a lot so I used logrotate to handle log truncation and rotation with this simple configuration file inside /etc/logrotate.d:

/home/user/project/log {
    daily
    rotate 4
    compress
    missingok
    copytruncate    
}

Logrotate is runned once a day with a simple cron job:

$ sudo crontab -l
0 0 * * * sudo logrotate /etc/logrotate.conf

It correctly runs, creating the log.n.gz files ecc, but the main file becomes a data file:

~ project $ file log
log: ASCII text, with escape sequences
~ project $ sudo logrotate -f /etc/logrotate.d/project
~ project $ file log
log: data

Why this behaviour? I tried to replace gzip with bzip2 in the /etc/logrotate.conf file, but the result is the same

0

There are 0 best solutions below