We need to keep only one log file of each service in our Ubuntu 20.04 servers. I've modified the /etc/logrotate.conf file as follows:
weekly
su root adm
rotate 0
create
ifempty
include /etc/logrotate.d
And for a specific service, think of misc for example, which makes the vmware-network.log log files, I have a config file in /etc/logrotate.d/misc which is as follows:
/var/log/vmware-network.*.log {
su root root
rotate 0
daily
missingok
ifempty
}
Now when I test my logrotation with logrotate -fv /etc/logrotate.conf, it doesn't delete any of vmware-network.*.log files, it just makes them zero in size. However when I use logrotate -fv /etc/logrotate.d/misc, it keeps only one vmware-network.log file and deletes other numbered log files.
logrotate doesn't do my desired job since it is reading from the default config file /etc/logrotate.conf. I want to know what is making this difference between these two config files and how to resolve it.
P.S:
All other config files of /etc/logrotate.d/ have the same behavior. they will keep one log file when forced to read from them. I only mentioned misc here because it has many vmware-network.log files and I can easily see the difference it makes.
The permissions and user/groups of mentioned log files and /var/log are:
-rw------- 1 root root vmware-network.log
drwxrwxr-x 15 root syslog /var/log/
I've tried different approaches with different configurations, but none of each worked. I've also added misc logrotation config into the logrotate.conf and executed it, but the output was still the same.
One common error I've run into was:
error: skipping "/var/log/vmware-network.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.
And I set different su directives for different config files, e.g su root adm for /etc/logrotate.d/rsyslog. Although it didn't send me the error, still not doing the job.
Any help would be appreciated.