1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| # '-d' 调试模式(不切分日志文件),并输出详细处理过程日志 $ logrotate -d -f /etc/logrotate.d/nginx
# '-f' 强制切分日志,'-v' 输出详细信息 $ logrotate -vf /etc/logrotate.d/nginx reading config file nginx Allocating hash table for state file, size 15360 B
Handling 1 logs
rotating pattern: /usr/local/nginx/logs/*.log forced from command line (100 rotations) empty log files are rotated, old logs are removed considering log /usr/local/nginx/logs/access.log log needs rotating considering log /usr/local/nginx/logs/error.log log needs rotating rotating log /usr/local/nginx/logs/access.log, log->rotateCount is 100 dateext suffix '-20201121' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' glob finding old rotated logs failed rotating log /usr/local/nginx/logs/error.log, log->rotateCount is 100 dateext suffix '-20201121' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' glob finding old rotated logs failed renaming /usr/local/nginx/logs/access.log to /usr/local/nginx/logs/access.log-20201121 renaming /usr/local/nginx/logs/error.log to /usr/local/nginx/logs/error.log-20201121 running postrotate script
# 切分后的日志文件 $ ls -lt /usr/local/nginx/logs 总用量 0 -rw-r--r-- 1 nginx root 0 11月 21 18:58 access.log -rw-r--r-- 1 nginx root 0 11月 21 18:57 access.log-20201121 -rw-r--r-- 1 nginx root 0 11月 21 18:58 error.log -rw-r--r-- 1 nginx root 0 11月 21 18:57 error.log-20201121 -rw-r--r-- 1 nginx root 0 11月 21 18:58 images.log -rw-r--r-- 1 nginx root 0 11月 21 18:57 images.log-20201121
|