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' session.timing.1
endscript
But as I am applying this to bunchg of files I don't have any specific name like session.timing.1
is there any way to get it done generically? I want this operation to be done for all file of typeA_date1.log
typeA_date2.log
and so on....
Or do you suggest any other method that can be useful here?