{"id":5414,"date":"2020-07-30T13:11:21","date_gmt":"2020-07-30T05:11:21","guid":{"rendered":"http:\/\/39.97.231.10\/?p=5414"},"modified":"2020-07-30T13:11:21","modified_gmt":"2020-07-30T05:11:21","slug":"logrotate%e6%97%a5%e5%bf%97%e5%88%86%e5%89%b2%e5%b7%a5%e5%85%b7","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=5414","title":{"rendered":"Logrotate\u65e5\u5fd7\u5206\u5272\u5de5\u5177"},"content":{"rendered":"<h2>1\u3001\u5173\u4e8e\u65e5\u5fd7\u5207\u5272<\/h2>\n<p>\u65e5\u5fd7\u6587\u4ef6\u5305\u542b\u4e86\u5173\u4e8e\u7cfb\u7edf\u4e2d\u53d1\u751f\u7684\u4e8b\u4ef6\u7684\u6709\u7528\u4fe1\u606f\uff0c\u5728\u6392\u969c\u8fc7\u7a0b\u4e2d\u6216\u8005\u7cfb\u7edf\u6027\u80fd\u5206\u6790\u65f6\u7ecf\u5e38\u88ab\u7528\u5230\u3002\u5bf9\u4e8e\u5fd9\u788c\u7684\u670d\u52a1\u5668\uff0c\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u4f1a\u589e\u957f\u6781\u5feb\uff0c\u670d\u52a1\u5668\u4f1a\u5f88\u5feb\u6d88\u8017\u78c1\u76d8\u7a7a\u95f4\uff0c\u8fd9\u6210\u4e86\u4e2a\u95ee\u9898\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5904\u7406\u4e00\u4e2a\u5355\u4e2a\u7684\u5e9e\u5927\u65e5\u5fd7\u6587\u4ef6\u4e5f\u5e38\u5e38\u662f\u4ef6\u5341\u5206\u68d8\u624b\u7684\u4e8b\u3002<br \/>\nlogrotate\u662f\u4e2a\u5341\u5206\u6709\u7528\u7684\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u81ea\u52a8\u5bf9\u65e5\u5fd7\u8fdb\u884c\u622a\u65ad\uff08\u6216\u8f6e\u5faa\uff09\u3001\u538b\u7f29\u4ee5\u53ca\u5220\u9664\u65e7\u7684\u65e5\u5fd7\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u8bbe\u7f6elogrotate\uff0c\u8ba9\/var\/log\/foo\u65e5\u5fd7\u6587\u4ef6\u6bcf30\u5929\u8f6e\u5faa\uff0c\u5e76\u5220\u9664\u8d85\u8fc76\u4e2a\u6708\u7684\u65e5\u5fd7\u3002\u914d\u7f6e\u5b8c\u540e\uff0clogrotate\u7684\u8fd0\u4f5c\u5b8c\u5168\u81ea\u52a8\u5316\uff0c\u4e0d\u5fc5\u8fdb\u884c\u4efb\u4f55\u8fdb\u4e00\u6b65\u7684\u4eba\u4e3a\u5e72\u9884\u3002<\/p>\n<h2>2\u3001\u5b89\u88c5logrotate<\/h2>\n<p>\u7cfb\u7edf\u7248\u672c\u8bf4\u660e<br \/>\n[root@clsn6 ~]# cat \/etc\/redhat-release CentOS release 6.9 (Final) [root@clsn6 ~]# uname -r 2.6.32-696.el6.x86_64<br \/>\n\u9ed8\u8ba4centos\u7cfb\u7edf\u5b89\u88c5\u81ea\u5e26logrotate\uff0c\u5b89\u88c5\u65b9\u6cd5\u5982\u4e0b<br \/>\nyum -y install logrotate crontabs<br \/>\n\u8f6f\u4ef6\u5305\u4fe1\u606f\u8bf4\u660e<br \/>\n[root@clsn6 ~]# rpm -ql logrotate \/etc\/cron.daily\/logrotate \/etc\/logrotate.conf # \u4e3b\u914d\u7f6e\u6587\u4ef6 \/etc\/logrotate.d # \u914d\u7f6e\u76ee\u5f55<br \/>\nlogrotate\u7684\u914d\u7f6e\u6587\u4ef6\u662f\/etc\/logrotate.conf\uff0c\u901a\u5e38\u4e0d\u9700\u8981\u5bf9\u5b83\u8fdb\u884c\u4fee\u6539\u3002\u65e5\u5fd7\u6587\u4ef6\u7684\u8f6e\u5faa\u8bbe\u7f6e\u5728\u72ec\u7acb\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u5b83\uff08\u4eec\uff09\u653e\u5728\/etc\/logrotate.d\/\u76ee\u5f55\u4e0b\u3002<\/p>\n<h2>3\u3001\u5b9e\u8df5\u914d\u7f6elogrotate<\/h2>\n<h3>3.1 \u6d4b\u8bd5logrotate\u5982\u4f55\u7ba1\u7406\u65e5\u5fd7<\/h3>\n<p>\u8fd9\u91cc\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a10MB\u7684\u65e5\u5fd7\u6587\u4ef6\/var\/log\/log-file\u3002\u6211\u4eec\u5c06\u5c55\u793a\u600e\u6837\u4f7f\u7528logrotate\u6765\u7ba1\u7406\u8be5\u65e5\u5fd7\u6587\u4ef6\u3002<br \/>\n\u6211\u4eec\u4ece\u521b\u5efa\u4e00\u4e2a\u65e5\u5fd7\u6587\u4ef6\u5f00\u59cb\u5427\uff0c\u7136\u540e\u5728\u5176\u4e2d\u586b\u5165\u4e00\u4e2a10MB\u7684\u968f\u673a\u6bd4\u7279\u6d41\u6570\u636e\u6587\u4ef6\u3002<br \/>\n[root@clsn6 ~]# touch \/var\/log\/log-file [root@clsn6 ~]# head -c 10M &lt; \/dev\/urandom &gt; \/var\/log\/log-file<br \/>\n\u7531\u4e8e\u73b0\u5728\u65e5\u5fd7\u6587\u4ef6\u5df2\u7ecf\u51c6\u5907\u597d\uff0c\u6211\u4eec\u5c06\u914d\u7f6elogrotate\u6765\u8f6e\u5faa\u8be5\u65e5\u5fd7\u6587\u4ef6\u3002\u8ba9\u6211\u4eec\u4e3a\u8be5\u6587\u4ef6\u521b\u5efa\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u3002<br \/>\n[root@clsn6 ~]# vim \/etc\/logrotate.d\/log-file \/var\/log\/log-file { monthly rotate 5 compress delaycompress missingok notifempty create 644 root root postrotate \/usr\/bin\/killall -HUP rsyslogd endscript }<br \/>\n\u4e0a\u9762\u7684\u6a21\u677f\u662f\u901a\u7528\u7684\uff0c\u800c\u914d\u7f6e\u53c2\u6570\u5219\u6839\u636e\u4f60\u7684\u9700\u6c42\u8fdb\u884c\u8c03\u6574\uff0c\u4e0d\u662f\u6240\u6709\u7684\u53c2\u6570\u90fd\u662f\u5fc5\u8981\u7684\u3002\u4e5f\u53ef\u4ee5\u901a\u8fc7man\u624b\u518c\u4e2d\u7684\u4f8b\u5b50\u8fdb\u884c\u914d\u7f6e\u3002<\/p>\n<h3>3.2\u914d\u7f6e\u6587\u4ef6\u8bf4\u660e<\/h3>\n<table>\n<tbody>\n<tr>\n<td width=\\\"29%\\\">\u914d\u7f6e\u53c2\u6570<\/td>\n<td width=\\\"70%\\\">\u8bf4\u660e<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">monthly<\/td>\n<td width=\\\"70%\\\">\u65e5\u5fd7\u6587\u4ef6\u5c06\u6309\u6708\u8f6e\u5faa\u3002\u5176\u5b83\u53ef\u7528\u503c\u4e3a\\&#8217;daily\\&#8217;\uff0c\\&#8217;weekly\\&#8217;\u6216\u8005\\&#8217;yearly\\&#8217;\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">rotate 5<\/td>\n<td width=\\\"70%\\\">\u4e00\u6b21\u5c06\u5b58\u50a85\u4e2a\u5f52\u6863\u65e5\u5fd7\u3002\u5bf9\u4e8e\u7b2c\u516d\u4e2a\u5f52\u6863\uff0c\u65f6\u95f4\u6700\u4e45\u7684\u5f52\u6863\u5c06\u88ab\u5220\u9664\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">compress<\/td>\n<td width=\\\"70%\\\">\u5728\u8f6e\u5faa\u4efb\u52a1\u5b8c\u6210\u540e\uff0c\u5df2\u8f6e\u5faa\u7684\u5f52\u6863\u5c06\u4f7f\u7528gzip\u8fdb\u884c\u538b\u7f29\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">delaycompress<\/td>\n<td width=\\\"70%\\\">\u603b\u662f\u4e0ecompress\u9009\u9879\u4e00\u8d77\u7528\uff0cdelaycompress\u9009\u9879\u6307\u793alogrotate\u4e0d\u8981\u5c06\u6700\u8fd1\u7684\u5f52\u6863\u538b\u7f29\uff0c\u538b\u7f29\u5c06\u5728\u4e0b\u4e00\u6b21\u8f6e\u5faa\u5468\u671f\u8fdb\u884c\u3002\u8fd9\u5728\u4f60\u6216\u4efb\u4f55\u8f6f\u4ef6\u4ecd\u7136\u9700\u8981\u8bfb\u53d6\u6700\u65b0\u5f52\u6863\u65f6\u5f88\u6709\u7528\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">missingok<\/td>\n<td width=\\\"70%\\\">\u5728\u65e5\u5fd7\u8f6e\u5faa\u671f\u95f4\uff0c\u4efb\u4f55\u9519\u8bef\u5c06\u88ab\u5ffd\u7565\uff0c\u4f8b\u5982\u201c\u6587\u4ef6\u65e0\u6cd5\u627e\u5230\u201d\u4e4b\u7c7b\u7684\u9519\u8bef\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">notifempty<\/td>\n<td width=\\\"70%\\\">\u5982\u679c\u65e5\u5fd7\u6587\u4ef6\u4e3a\u7a7a\uff0c\u8f6e\u5faa\u4e0d\u4f1a\u8fdb\u884c\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">create 644 root root<\/td>\n<td width=\\\"70%\\\">\u4ee5\u6307\u5b9a\u7684\u6743\u9650\u521b\u5efa\u5168\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u540c\u65f6logrotate\u4e5f\u4f1a\u91cd\u547d\u540d\u539f\u59cb\u65e5\u5fd7\u6587\u4ef6\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">postrotate\/endscript<\/td>\n<td width=\\\"70%\\\">\u5728\u6240\u6709\u5176\u5b83\u6307\u4ee4\u5b8c\u6210\u540e\uff0cpostrotate\u548cendscript\u91cc\u9762\u6307\u5b9a\u7684\u547d\u4ee4\u5c06\u88ab\u6267\u884c\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0crsyslogd\u00a0\u8fdb\u7a0b\u5c06\u7acb\u5373\u518d\u6b21\u8bfb\u53d6\u5176\u914d\u7f6e\u5e76\u7ee7\u7eed\u8fd0\u884c\u3002<\/td>\n<\/tr>\n<tr>\n<td colspan=\\\"2\\\" width=\\\"100%\\\">\u4ee5\u4e0a\u4fe1\u606f\u6765\u6e90\u00a0\\&#8221;man logrotate\\&#8221;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u00a03.3\u624b\u52a8\u8fd0\u884clogrotate<\/h3>\n<p>logrotate\u53ef\u4ee5\u5728\u4efb\u4f55\u65f6\u5019\u4ece\u547d\u4ee4\u884c\u624b\u52a8\u8c03\u7528\u3002\u8981\u8c03\u7528\u4e3a\/etc\/lograte.d\/\u4e0b\u914d\u7f6e\u7684\u6240\u6709\u65e5\u5fd7\u8c03\u7528logrotate\uff1a<br \/>\n[root@clsn6 ~]# logrotate \/etc\/logrotate.conf<br \/>\n\u8981\u4e3a\u67d0\u4e2a\u7279\u5b9a\u7684\u914d\u7f6e\u8c03\u7528logrotate,\u6267\u884c\u4e00\u6b21\u5207\u5272\u4efb\u52a1\u6d4b\u8bd5<br \/>\n[root@clsn6 ~]# ll \/var\/log\/log-file -rw-r&#8211;r&#8211; 1 root root 10485760 Feb 7 18:50 \/var\/log\/log-file [root@clsn6 ~]# logrotate -vf \/etc\/logrotate.d\/log-file [root@clsn6 ~]# ll \/var\/log\/log-file* -rw-r&#8211;r&#8211; 1 root root 0 Feb 7 19:17 \/var\/log\/log-file -rw-r&#8211;r&#8211; 1 root root 10485760 Feb 7 18:50 \/var\/log\/log-file.1<br \/>\n\u5373\u4f7f\u8f6e\u5faa\u6761\u4ef6\u6ca1\u6709\u6ee1\u8db3\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u2018-f\u2019\u9009\u9879\u6765\u5f3a\u5236logrotate\u8f6e\u5faa\u65e5\u5fd7\u6587\u4ef6\uff0c\u2018-v\u2019\u53c2\u6570\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684\u8f93\u51fa\u3002<\/p>\n<h3>3.4Logrotate\u7684\u8bb0\u5f55\u65e5\u5fd7<\/h3>\n<p>logrotate\u81ea\u8eab\u7684\u65e5\u5fd7\u901a\u5e38\u5b58\u653e\u4e8e\/var\/lib\/logrotate\/status\u76ee\u5f55\u3002\u5982\u679c\u5904\u4e8e\u6392\u969c\u76ee\u7684\uff0c\u6211\u4eec\u60f3\u8981logrotate\u8bb0\u5f55\u5230\u4efb\u4f55\u6307\u5b9a\u7684\u6587\u4ef6\uff0c\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u50cf\u4e0b\u9762\u8fd9\u6837\u4ece\u547d\u4ee4\u884c\u6307\u5b9a\u3002<br \/>\n[root@clsn6 ~]# logrotate -vf -s \/var\/log\/logrotate-status \/etc\/logrotate.d\/log-file reading config file \/etc\/logrotate.d\/log-file reading config info for \/var\/log\/log-file Handling 1 logs rotating pattern: \/var\/log\/log-file forced from command line (5 rotations) empty log files are not rotated, old logs are removed considering log \/var\/log\/log-file log does not need rotating not running postrotate script, since no logs were rotated<\/p>\n<h3>3.5 Logrotate\u5b9a\u65f6\u4efb\u52a1<\/h3>\n<p>logrotate\u9700\u8981\u7684cron\u4efb\u52a1\u5e94\u8be5\u5728\u5b89\u88c5\u65f6\u5c31\u81ea\u52a8\u521b\u5efa\u4e86\uff0c\u6211\u628acron\u6587\u4ef6\u7684\u5185\u5bb9\u8d34\u51fa\u6765\uff0c\u4ee5\u4f9b\u5927\u5bb6\u53c2\u8003\u3002<br \/>\n[root@clsn6 ~]# cat \/etc\/cron.daily\/logrotate #!\/bin\/sh \/usr\/sbin\/logrotate \/etc\/logrotate.conf EXITVALUE=$? if [ $EXITVALUE != 0 ]; then \/usr\/bin\/logger -t logrotate \\&#8221;ALERT exited abnormally with [$EXITVALUE]\\&#8221; fi exit 0<\/p>\n<h2>4\u3001logrotate\u751f\u4ea7\u5e94\u7528<\/h2>\n<h3>4.1\u4e3anginx\u8bbe\u7f6e\u65e5\u5fd7\u5207\u5272<\/h3>\n<p>\u9632\u6b62\u8bbf\u95ee\u65e5\u5fd7\u6587\u4ef6\u8fc7\u5927<br \/>\n[root@clsn nginx]# cat \/etc\/logrotate.d\/nginx \/var\/log\/nginx\/*.log { daily rotate 5 missingok notifempty create 644 www www postrotate if [ -f \/application\/nginx\/logs\/nginx.pid ]; then kill -USR1 `cat \/application\/nginx\/logs\/nginx.pid` fi endscript }<br \/>\nlogrotate\u5de5\u5177\u5bf9\u4e8e\u9632\u6b62\u56e0\u5e9e\u5927\u7684\u65e5\u5fd7\u6587\u4ef6\u800c\u8017\u5c3d\u5b58\u50a8\u7a7a\u95f4\u662f\u5341\u5206\u6709\u7528\u7684\u3002\u914d\u7f6e\u5b8c\u6bd5\u540e\uff0c\u8fdb\u7a0b\u662f\u5168\u81ea\u52a8\u7684\uff0c\u53ef\u4ee5\u957f\u65f6\u95f4\u5728\u4e0d\u9700\u8981\u4eba\u4e3a\u5e72\u9884\u4e0b\u8fd0\u884c\u3002\u672c\u6559\u7a0b\u91cd\u70b9\u5173\u6ce8\u51e0\u4e2a\u4f7f\u7528logrotate\u7684\u51e0\u4e2a\u57fa\u672c\u6837\u4f8b\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5b9a\u5236\u5b83\u4ee5\u6ee1\u8db3\u4f60\u7684\u9700\u6c42\u3002<br \/>\n\u5bf9\u4e8e\u5176\u4ed6\u670d\u52a1\u65e5\u5fd7\u5207\u5272\u540e\u7eed\u8865\u5145<\/p>\n<h2>5\u3001\u9644\u5f55<\/h2>\n<h3>5.1\u5173\u4e8eUSR1\u4fe1\u53f7\u89e3\u91ca<\/h3>\n<p>\u6458\u81ea\uff1a http:\/\/www.xuebuyuan.com\/323422.html<br \/>\nUSR1\u4ea6\u901a\u5e38\u88ab\u7528\u6765\u544a\u77e5\u5e94\u7528\u7a0b\u5e8f\u91cd\u8f7d\u914d\u7f6e\u6587\u4ef6\uff1b\u4f8b\u5982\uff0c\u5411Apache HTTP\u670d\u52a1\u5668\u53d1\u9001\u4e00\u4e2aUSR1\u4fe1\u53f7\u5c06\u5bfc\u81f4\u4ee5\u4e0b\u6b65\u9aa4\u7684\u53d1\u751f\uff1a\u505c\u6b62\u63a5\u53d7\u65b0\u7684\u8fde\u63a5\uff0c\u7b49\u5f85\u5f53\u524d\u8fde\u63a5\u505c\u6b62\uff0c\u91cd\u65b0\u8f7d\u5165\u914d\u7f6e\u6587\u4ef6\uff0c\u91cd\u65b0\u6253\u5f00\u65e5\u5fd7\u6587\u4ef6\uff0c\u91cd\u542f\u670d\u52a1\u5668\uff0c\u4ece\u800c\u5b9e\u73b0\u76f8\u5bf9\u5e73\u6ed1\u7684\u4e0d\u5173\u673a\u7684\u66f4\u6539\u3002\u5185\u5bb9\u6458\u81eawiki\uff1ahttp:\/\/zh.wikipedia.org\/wiki\/SIGUSR1%E5%92%8CSIGUSR2<br \/>\n\u5bf9\u4e8eUSR1\u548c2\u90fd\u53ef\u4ee5\u7528\u6237\u81ea\u5b9a\u4e49\u7684\uff0c\u5728POSIX\u517c\u5bb9\u7684\u5e73\u53f0\u4e0a\uff0cSIGUSR1\u548cSIGUSR2\u662f\u53d1\u9001\u7ed9\u4e00\u4e2a\u8fdb\u7a0b\u7684\u4fe1\u53f7\uff0c\u5b83\u8868\u793a\u4e86\u7528\u6237\u5b9a\u4e49\u7684\u60c5\u51b5\u3002\u5b83\u4eec\u7684\u7b26\u53f7\u5e38\u91cf\u5728\u5934\u6587\u4ef6signal.h\u4e2d\u5b9a\u4e49\u3002\u5728\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\uff0c\u4fe1\u53f7\u7684\u7f16\u53f7\u53ef\u80fd\u53d1\u751f\u53d8\u5316\uff0c\u56e0\u6b64\u9700\u8981\u4f7f\u7528\u7b26\u53f7\u540d\u79f0\u3002<br \/>\nkill -HUP pid \u6216\u8005 killall -HUP pName\uff1a<br \/>\n\u5176\u4e2dpid\u662f\u8fdb\u7a0b\u6807\u8bc6\uff0cpName\u662f\u8fdb\u7a0b\u7684\u540d\u79f0\u3002<br \/>\n\u5982\u679c\u60f3\u8981\u66f4\u6539\u914d\u7f6e\u800c\u4e0d\u9700\u505c\u6b62\u5e76\u91cd\u65b0\u542f\u52a8\u670d\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0a\u9762\u4e24\u4e2a\u547d\u4ee4\u3002\u5728\u5bf9\u914d\u7f6e\u6587\u4ef6\u4f5c\u5fc5\u8981\u7684\u66f4\u6539\u540e\uff0c\u53d1\u51fa\u8be5\u547d\u4ee4\u4ee5\u52a8\u6001\u66f4\u65b0\u670d\u52a1\u914d\u7f6e\u3002\u6839\u636e\u7ea6\u5b9a\uff0c\u5f53\u4f60\u53d1\u9001\u4e00\u4e2a\u6302\u8d77\u4fe1\u53f7(\u4fe1\u53f71\u6216HUP)\u65f6\uff0c\u5927\u591a\u6570\u670d\u52a1\u5668\u8fdb\u7a0b(\u6240\u6709\u5e38\u7528\u7684\u8fdb\u7a0b)\u90fd\u4f1a\u8fdb\u884c\u590d\u4f4d\u64cd\u4f5c\u5e76\u91cd\u65b0\u52a0\u8f7d\u5b83\u4eec\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<h3>5.2\u5e38\u89c1\u914d\u7f6e\u53c2\u6570\u5c0f\u7ed3<\/h3>\n<table>\n<tbody>\n<tr>\n<td width=\\\"29%\\\">\u914d\u7f6e\u53c2\u6570<\/td>\n<td width=\\\"70%\\\">\u8bf4\u660e<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">compress<\/td>\n<td width=\\\"70%\\\">\u901a\u8fc7gzip\u538b\u7f29\u8f6c\u50a8\u4ee5\u540e\u7684\u65e5\u5fd7<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">nocompress<\/td>\n<td width=\\\"70%\\\">\u4e0d\u538b\u7f29<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">copytruncate<\/td>\n<td width=\\\"70%\\\">\u7528\u4e8e\u8fd8\u5728\u6253\u5f00\u4e2d\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u628a\u5f53\u524d\u65e5\u5fd7\u5907\u4efd\u5e76\u622a\u65ad<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">nocopytruncate<\/td>\n<td width=\\\"70%\\\">\u5907\u4efd\u65e5\u5fd7\u6587\u4ef6\u4f46\u662f\u4e0d\u622a\u65ad<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">create\u00a0mode owner group<\/td>\n<td width=\\\"70%\\\">\u8f6c\u50a8\u6587\u4ef6\uff0c\u4f7f\u7528\u6307\u5b9a\u7684\u6587\u4ef6\u6a21\u5f0f\u521b\u5efa\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">nocreate<\/td>\n<td width=\\\"70%\\\">\u4e0d\u5efa\u7acb\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">delaycompress<\/td>\n<td width=\\\"70%\\\">\u548c\u00a0compress\u00a0\u4e00\u8d77\u4f7f\u7528\u65f6\uff0c\u8f6c\u50a8\u7684\u65e5\u5fd7\u6587\u4ef6\u5230\u4e0b\u4e00\u6b21\u8f6c\u50a8\u65f6\u624d\u538b\u7f29<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">nodelaycompress<\/td>\n<td width=\\\"70%\\\">\u8986\u76d6\u00a0delaycompress\u00a0\u9009\u9879\uff0c\u8f6c\u50a8\u540c\u65f6\u538b\u7f29\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">errors address<\/td>\n<td width=\\\"70%\\\">\u4e13\u50a8\u65f6\u7684\u9519\u8bef\u4fe1\u606f\u53d1\u9001\u5230\u6307\u5b9a\u7684Email\u00a0\u5730\u5740<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">ifempty<\/td>\n<td width=\\\"70%\\\">\u5373\u4f7f\u662f\u7a7a\u6587\u4ef6\u4e5f\u8f6c\u50a8\uff0c\u8fd9\u4e2a\u662f\u00a0logrotate\u00a0\u7684\u7f3a\u7701\u9009\u9879\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">notifempty<\/td>\n<td width=\\\"70%\\\">\u5982\u679c\u662f\u7a7a\u6587\u4ef6\u7684\u8bdd\uff0c\u4e0d\u8f6c\u50a8<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">mail\u00a0address<\/td>\n<td width=\\\"70%\\\">\u628a\u8f6c\u50a8\u7684\u65e5\u5fd7\u6587\u4ef6\u53d1\u9001\u5230\u6307\u5b9a\u7684E-mail\u00a0\u5730\u5740<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">nomail<\/td>\n<td width=\\\"70%\\\">\u8f6c\u50a8\u65f6\u4e0d\u53d1\u9001\u65e5\u5fd7\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">olddir\u00a0directory<\/td>\n<td width=\\\"70%\\\">\u8f6c\u50a8\u540e\u7684\u65e5\u5fd7\u6587\u4ef6\u653e\u5165\u6307\u5b9a\u7684\u76ee\u5f55\uff0c\u5fc5\u987b\u548c\u5f53\u524d\u65e5\u5fd7\u6587\u4ef6\u5728\u540c\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">noolddir<\/td>\n<td width=\\\"70%\\\">\u8f6c\u50a8\u540e\u7684\u65e5\u5fd7\u6587\u4ef6\u548c\u5f53\u524d\u65e5\u5fd7\u6587\u4ef6\u653e\u5728\u540c\u4e00\u4e2a\u76ee\u5f55\u4e0b<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">prerotate\/endscript<\/td>\n<td width=\\\"70%\\\">\u5728\u8f6c\u50a8\u4ee5\u524d\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4\u53ef\u4ee5\u653e\u5165\u8fd9\u4e2a\u5bf9\uff0c\u8fd9\u4e24\u4e2a\u5173\u952e\u5b57\u5fc5\u987b\u5355\u72ec\u6210\u884c<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">daily<\/td>\n<td width=\\\"70%\\\">\u6307\u5b9a\u8f6c\u50a8\u5468\u671f\u4e3a\u6bcf\u5929<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">weekly<\/td>\n<td width=\\\"70%\\\">\u6307\u5b9a\u8f6c\u50a8\u5468\u671f\u4e3a\u6bcf\u5468<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">monthly<\/td>\n<td width=\\\"70%\\\">\u6307\u5b9a\u8f6c\u50a8\u5468\u671f\u4e3a\u6bcf\u6708<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">rotate count<\/td>\n<td width=\\\"70%\\\">\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\u5220\u9664\u4e4b\u524d\u8f6c\u50a8\u7684\u6b21\u6570\uff0c0\u00a0\u6307\u6ca1\u6709\u5907\u4efd\uff0c5\u00a0\u6307\u4fdd\u75595\u00a0\u4e2a\u5907\u4efd<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">tabooext [+] list<\/td>\n<td width=\\\"70%\\\">\u8ba9logrotate\u4e0d\u8f6c\u50a8\u6307\u5b9a\u6269\u5c55\u540d\u7684\u6587\u4ef6\uff0c\u7f3a\u7701\u7684\u6269\u5c55\u540d\u662f\uff1a.rpm-orig, .rpmsave, v,\u00a0\u548c\u00a0~<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">size size<\/td>\n<td width=\\\"70%\\\">\u5f53\u65e5\u5fd7\u6587\u4ef6\u5230\u8fbe\u6307\u5b9a\u7684\u5927\u5c0f\u65f6\u624d\u8f6c\u50a8\uff0cbytes(\u7f3a\u7701)\u53caKB(sizek)\u6216MB(sizem)<\/td>\n<\/tr>\n<tr>\n<td width=\\\"29%\\\">missingok<\/td>\n<td width=\\\"70%\\\">\u5728\u65e5\u5fd7\u8f6e\u5faa\u671f\u95f4\uff0c\u4efb\u4f55\u9519\u8bef\u5c06\u88ab\u5ffd\u7565\uff0c\u4f8b\u5982\u201c\u6587\u4ef6\u65e0\u6cd5\u627e\u5230\u201d\u4e4b\u7c7b\u7684\u9519\u8bef\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5173\u4e8e\u65e5\u5fd7\u5207\u5272 \u65e5\u5fd7\u6587\u4ef6\u5305\u542b\u4e86\u5173\u4e8e\u7cfb\u7edf\u4e2d\u53d1\u751f\u7684\u4e8b\u4ef6\u7684\u6709\u7528\u4fe1\u606f\uff0c\u5728\u6392\u969c\u8fc7\u7a0b\u4e2d\u6216\u8005\u7cfb\u7edf\u6027\u80fd\u5206\u6790\u65f6\u7ecf\u5e38\u88ab\u7528\u5230\u3002\u5bf9\u4e8e &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=5414\"> <span class=\"screen-reader-text\">Logrotate\u65e5\u5fd7\u5206\u5272\u5de5\u5177<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[102,124],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"1\u3001\u5173\u4e8e\u65e5\u5fd7\u5207\u5272 \u65e5\u5fd7\u6587\u4ef6\u5305\u542b\u4e86\u5173\u4e8e\u7cfb\u7edf\u4e2d\u53d1\u751f\u7684\u4e8b\u4ef6\u7684\u6709\u7528\u4fe1\u606f\uff0c\u5728\u6392\u969c\u8fc7\u7a0b\u4e2d\u6216\u8005\u7cfb\u7edf\u6027\u80fd\u5206\u6790\u65f6\u7ecf\u5e38\u88ab\u7528\u5230\u3002\u5bf9\u4e8e&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5414"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5414"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5414\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5414"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}