I am using logrotate to manage my logs. As I have to manage a bunch of log files. My logrotate config looks like
/log/typeA*.log
/log/typeB*.log
/log/typeC*.log{
daily
rotate 7
copytruncate
size 1M
compress
su root root
create 0644 root root
missingok
}
After logrotation is complete I see bunch of null characters in the beginning of file. Which looks like
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
Looks like infinitely long string. Also file size looks similar. There is solution suggested https://serverfault.com/a/510470 to use postrotate script like
postrotate
sed -i -e 's/\o00//g' "$1"
endscript
But using this script will modify the file and change stream. So logs won't be redirected to some file stream which doesn't exist.
I am generating logs using python logging module