I run logrotate
through cron with the script
[alex@leia ~]$ cat /etc/cron.daily/logrotate
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf >/dev/null
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
which, according to the syslog, should work:
Dec 14 03:21:01 leia run-parts(/etc/cron.daily)[3041]: starting logrotate
Dec 14 03:21:01 leia run-parts(/etc/cron.daily)[3063]: finished logrotate
I expect this to also run the following directive:
[alex@leia ~]$ cat /etc/logrotate.d/www-data_uwsgi_nginx
/home/www-data/*/logs/*/*log {
rotate 5
size 20M
nocompress
missingok
postrotate
touch /tmp/uwsgi-reload
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
endscript
sharedscripts
}
But! It does not rotate the logs under /home/www-data
. Other logs get rotated. If I run logrotate
manually with
[alex@leia ~]$ sudo logrotate /etc/logrotate.conf
it does rotate the logs in question.
I saw the related question where the problem was with SELinux, and attempted that solution but it did not help in my case.
Edit: On request, the contents of /etc/logrotate.conf
:
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
weekly
andminsize 20M
specified. That means that the logfile will at most be rotated weekly, and then only if the size exceeds 20MB. So if you run it manually today, it won't be rotated again until at least next week, and then only if the size is large enough. Are you sure that's not the issue here? – wurtel Dec 15 '15 at 14:15size 20M
specified, notminsize
– so time intervals shouldn't matter for those files, should they?daily
is specified in the/etc/logrotate.d
file – does this not override the "general" settings in/etc/logrotate.conf
? – kqr Dec 15 '15 at 14:34daily
in your /etc/logrotate.d/www-data_uwsgi_nginx file. So theweekly
is not overridden. – wurtel Dec 15 '15 at 14:39