System Environment
Ubuntu 14.04LTS
Nginx 1.4.7 Edit the Nginx file under Logrotate
$ Vim/etc/logrotate.d/nginx
/usr/local/nginx/logs/*.log {//log location
su root list //Use root permission , if not used may report permissions related to the issue following the mention
daily// run once a day
Missingok //If the log file is missing, do not error continue to perform the next
rotate 7 // Log save 7 days
dateext//File suffix is a date format, that is, after the cut file is: xxx.log-20131216.gz So, if commented out, cut out is by the number increment, that is said before xxx.log-1 this format
Notifempty //If it is an empty file, do not dump the permissions of Create 0640 root/log file
sharedscripts
prerotate
if [-d/etc/logrotate.d/httpd-prerotate]; then \
run-parts/etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
[-s/run/ Nginx.pid] && kill-usr1 ' cat/run/nginx.pid '
endscript
}
The file with the date in the back is generated, which indicates success.
Test
$/usr/sbin/logrotate-f/etc/logrotate.d/nginx
//If a file is generated indicates a successful configuration
Add to Crontab
12:10 Daily * * * * /usr/sbin/logrotate-f/etc/logrotate.d/nginx
Error Handling
May report this error if no SU root list is added
... insecure permissions (It ' s world writable or writable by group which are not ...
... error:skipping "/usr/local/nginx/logs/access.log" because parent directory ...