I rotate my nginx access log files with logrotate an have the following config:
/var/www/logs/*.log {
daily
missingok
dateext
dateformat _%Y-%m-%d
dateyesterday
rotate 90
compress
delaycompress
compressext
notifempty
create 0640 www-data www-data
sharedscripts
postrotate
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
endscript
}
When cron runs that script for example at 5am all logs between 0am and 5am in the file will be rotated. I want a log file for exactly one day from midnight to 11.59pm
Is there an opportunity to configure this?
To rotate the log at 11.59pm configure the /etc/crontab file as follow :
59 23 * * * <path_to_logrotate_command> -f <path_to_logrotate_schedule_file>
E.g. 59 23 * * * /usr/sbin/logrotate -f /home/foo/logrotate/rotate_nginx