Whats the best way to rotate nginx logfiles? In my opinion, I should create a file "nginx" in /etc/logrotate.d/ and fill it with the following code and do a /etc/init.d/syslog restart after that.
This would be my config (I havn't tested it yet):
#rotate the logfile(s) daily
# adds extension like YYYYMMDD instead of simply adding a number
# If log file is missing, go on to next one without issuing an error msg
# Save logfiles for the last 49 days
# Old versions of log files are compressed with gzip
# Postpone compression of the previous log file to the next rotation cycle
# Do not rotate the log if it is empty
# create mode owner group
create 644 nginx nginx
#after logfile is rotated and nginx.pid exists, send the USR1 signal
[ ! -f /usr/local/nginx/logs/nginx.pid ] || kill -USR1 `cat
I have both the access.log and error.log files in /usr/local/nginx/logs/ and want to rotate both daily. Can anyone please tell me if "dateext" is correct? I want the log filename to be something like "access.log-2010-12-04". One more thing: Can I do the log rotation every day on a specific time (e.g. 11 pm)? If so, how? Thanks.