{"id":287935,"date":"2023-11-24T20:10:22","date_gmt":"2023-11-24T12:10:22","guid":{"rendered":"https:\/\/lrxjmw.cn\/lsrljrml.html"},"modified":"2023-11-24T20:10:22","modified_gmt":"2023-11-24T12:10:22","slug":"lsrljrml","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lsrljrml.html","title":{"rendered":"linux rotatelogs \u6df1\u5165\u4e86\u89e3rotatelogs\u547d\u4ee4"},"content":{"rendered":"

1.\u4ec0\u4e48\u662flinux rotatelogs<\/strong>\u547d\u4ee4<\/a><\/b><\/p>\n

2. rotatelogs\u547d\u4ee4\u7684\u57fa\u672c\u7528\u6cd5<\/b><\/p>\n

3.\u4f7f\u7528rotatelogs\u547d\u4ee4\u5b9e\u73b0\u65e5\u5fd7\u5207\u5272<\/b><\/p>\n

4.\u4f7f\u7528rotatelogs\u547d\u4ee4\u5b9e\u73b0\u65e5\u5fd7\u5f52\u6863<\/b><\/p>\n

5.\u4f7f\u7528rotatelogs\u547d\u4ee4\u8bbe\u7f6e\u5207\u5272\u5468\u671f<\/b><\/p>\n

6.\u4f7f\u7528rotatelogs\u547d\u4ee4\u8bbe\u7f6e\u65e5\u5fd7\u6587\u4ef6\u540d\u683c\u5f0f<\/b><\/p>\n

7. rotatelogs\u547d\u4ee4\u7684\u9ad8\u7ea7\u7528\u6cd5\uff1a\u5408\u5e76\u65e5\u5fd7\u6d41<\/b><\/p>\n

8. rotatelogs\u547d\u4ee4\u7684\u9ad8\u7ea7\u7528\u6cd5\uff1a\u81ea\u5b9a\u4e49\u65e5\u5fd7\u5207\u5272\u6761\u4ef6<\/p>\n

9. rotatelogs\u547d\u4ee4\u7684\u9ad8\u7ea7\u7528\u6cd5\uff1a\u7ed3\u5408\u5176\u4ed6\u5de5\u5177\u5b9e\u73b0\u66f4\u5f3a\u5927\u7684\u65e5\u5fd7\u7ba1\u7406\u529f\u80fd<\/p>\n

10. rotatelogs\u547d\u4ee4\u7684\u6ce8\u610f\u4e8b\u9879\u548c\u5e38\u89c1\u95ee\u9898\u89e3\u7b54<\/b><\/p>\n

\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528linux\u7cfb\u7edf<\/a>\u4e2d\u7684rotatelogs\u547d\u4ee4\u6765\u5b9e\u73b0\u65e5\u5fd7\u5207\u5272\u548c\u5f52\u6863\u3002\u901a\u8fc7\u5408\u7406\u914d\u7f6erotatelogs\u547d\u4ee4\uff0c\u53ef\u4ee5\u6709\u6548\u7ba1\u7406\u65e5\u5fd7\u6587\u4ef6linux rotatelogs<\/strong>\uff0c\u907f\u514d\u65e5\u5fd7\u6587\u4ef6\u8fc7\u5927\u5bfc\u81f4\u7cfb\u7edf\u6027\u80fd\u4e0b\u964d\uff0c\u540c\u65f6\u4e5f\u65b9\u4fbf\u67e5\u9605\u548c\u5206\u6790\u5386\u53f2\u65e5\u5fd7\u3002<\/p>\n

1.\u4ec0\u4e48\u662flinux rotatelogs<\/strong>\u547d\u4ee4<\/b><\/p>\n

Linux<\/a>\u7cfb\u7edf\u4e2d\u7684rotatelogs\u662f\u4e00\u4e2a\u7528\u4e8e\u5207\u5272\u548c\u5f52\u6863Apache HTTP\u670d\u52a1\u5668\u65e5\u5fd7\u6587\u4ef6\u7684\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u6839\u636e\u8bbe\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u6216\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\uff0c\u81ea\u52a8\u5c06\u5f53\u524d\u65e5\u5fd7\u6587\u4ef6\u5207\u5272\u4e3a\u6307\u5b9a\u5927\u5c0f\u7684\u591a\u4e2a\u6587\u4ef6\uff0c\u5e76\u5bf9\u65e7\u7684\u65e5\u5fd7\u6587\u4ef6\u8fdb\u884c\u5f52\u6863\u3002\u8fd9\u6837\u5c31\u53ef\u4ee5\u4fdd\u6301\u65e5\u5fd7\u6587\u4ef6\u7684\u53ef\u8bfb\u6027\u548c\u7ba1\u7406\u6027\uff0c\u540c\u65f6\u4e5f\u4fbf\u4e8e\u8fdb\u884c\u65e5\u5fd7\u5206\u6790\u548c\u6545\u969c\u6392\u67e5\u3002<\/p>\n

2. rotatelogs\u547d\u4ee4\u7684\u57fa\u672c\u7528\u6cd5<\/b><\/p>\n

rotatelogs\u547d\u4ee4\u7684\u57fa\u672c\u7528\u6cd5\u975e\u5e38\u7b80\u535564\u4f4dlinux\uff0c\u53ea\u9700\u8981\u6307\u5b9a\u8f93\u5165\u65e5\u5fd7\u6587\u4ef6\u3001\u8f93\u51fa\u65e5\u5fd7\u6587\u4ef6\u548c\u5207\u5272\u5468\u671f\u5373\u53ef\u3002\u5177\u4f53\u547d\u4ee4\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n

\n

\nrotatelogs [\u9009\u9879]\u65e5\u5fd7\u6587\u4ef6\u5207\u5272\u5468\u671f\n<\/pre>\n<\/p>\n

\u5176\u4e2d\uff0c\u9009\u9879\u5305\u62ec\uff1a<\/p>\n

--l\uff1a\u4ee5\u672c\u5730\u65f6\u95f4\u683c\u5f0f\u8bb0\u5f55\u65e5\u5fd7<\/p>\n

--f\uff1a\u5f3a\u5236\u5237\u65b0\u7f13\u51b2\u533a<\/p>\n

--n\uff1a\u6307\u5b9a\u4fdd\u7559\u7684\u5f52\u6863\u65e5\u5fd7\u6587\u4ef6\u6570\u91cf<\/p>\n

3.\u4f7f\u7528rotatelogs\u547d\u4ee4\u5b9e\u73b0\u65e5\u5fd7\u5207\u5272<\/b><\/p>\n

\u901a\u8fc7\u8bbe\u7f6e\u5207\u5272\u5468\u671f\uff0c\u53ef\u4ee5\u5b9e\u73b0\u6309\u7167\u65f6\u95f4\u95f4\u9694\u8fdb\u884c\u65e5\u5fd7\u5207\u5272\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u6bcf\u5929\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\uff1a<\/p>\n

\n

\nrotatelogs -l\/var\/log\/access.log.%Y-%m-%d 86400\n<\/pre>\n<\/p>\n

\u8fd9\u6837\u5c31\u53ef\u4ee5\u6bcf\u5929\u751f\u6210\u4e00\u4e2a\u4ee5\u65e5\u671f\u547d\u540d\u7684\u65b0\u7684access.log\u6587\u4ef6\uff0c\u5e76\u5c06\u65e7\u7684access.log\u6587\u4ef6\u5f52\u6863\u3002<\/p>\n

4.\u4f7f\u7528rotatelogs\u547d\u4ee4\u5b9e\u73b0\u65e5\u5fd7\u5f52\u6863<\/b><\/p>\n

\u9664\u4e86\u6309\u7167\u65f6\u95f4\u95f4\u9694\u8fdb\u884c\u5207\u5272\u5916linux rotatelogs<\/strong>\uff0c\u8fd8\u53ef\u4ee5\u6839\u636e\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u6765\u8fdb\u884c\u5207\u5272\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u5728\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u8fbe\u5230100MB\u65f6\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\uff1a<\/p>\n

\n

\nrotatelogs -l\/var\/log\/access.log 100M\n<\/pre>\n<\/p>\n

\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728access.log\u6587\u4ef6\u5927\u5c0f\u8fbe\u5230100MB\u65f6\u751f\u6210\u4e00\u4e2a\u65b0\u7684access.log\u6587\u4ef6\uff0c\u5e76\u5c06\u65e7\u7684access.log\u6587\u4ef6\u5f52\u6863\u3002<\/p>\n

5.\u4f7f\u7528rotatelogs\u547d\u4ee4\u8bbe\u7f6e\u5207\u5272\u5468\u671f<\/b><\/p>\n

\u5207\u5272\u5468\u671f\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a\u65f6\u95f4\u95f4\u9694\u6216\u8005\u6309\u7167\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u6765\u8bbe\u7f6e\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u6bcf\u5c0f\u65f6\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\uff1a<\/p>\n

\n

\nrotatelogs -l\/var\/log\/access.log.%H 3600\n<\/pre>\n<\/p>\n

\u8fd9\u6837\u5c31\u53ef\u4ee5\u6bcf\u5c0f\u65f6\u751f\u6210\u4e00\u4e2a\u4ee5\u5c0f\u65f6\u6570\u547d\u540d\u7684\u65b0\u7684access.log\u6587\u4ef6\uff0c\u5e76\u5c06\u65e7\u7684access.log\u6587\u4ef6\u5f52\u6863\u3002<\/p>\n

6.\u4f7f\u7528rotatelogs\u547d\u4ee4\u8bbe\u7f6e\u65e5\u5fd7\u6587\u4ef6\u540d\u683c\u5f0f<\/b><\/p>\n

\u901a\u8fc7\u5728\u8f93\u51fa\u65e5\u5fd7\u6587\u4ef6\u8def\u5f84\u4e2d\u4f7f\u7528\u7279\u5b9a\u7684\u5360\u4f4d\u7b26\uff0c\u53ef\u4ee5\u5b9e\u73b0\u81ea\u5b9a\u4e49\u65e5\u5fd7\u6587\u4ef6\u540d\u683c\u5f0f\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u6bcf\u5929\u751f\u6210\u4e00\u4e2a\u4ee5\u65e5\u671f\u548c\u65f6\u95f4\u547d\u540d\u7684\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\uff1a<\/p>\n

\n

\nrotatelogs -l\/var\/log\/access.log.%Y-%m-%d_%H-%M-%S 86400\n<\/pre>\n<\/p>\n

\u8fd9\u6837\u5c31\u53ef\u4ee5\u6bcf\u5929\u751f\u6210\u4e00\u4e2a\u4ee5\u65e5\u671f\u548c\u65f6\u95f4\u547d\u540d\u7684\u65b0\u7684access.log\u6587\u4ef6linux\u6587\u672c\u7f16\u8f91\u5668\uff0c\u5e76\u5c06\u65e7\u7684access.log\u6587\u4ef6\u5f52\u6863\u3002<\/p>\n

7. rotatelogs\u547d\u4ee4\u7684\u9ad8\u7ea7\u7528\u6cd5\uff1a\u5408\u5e76\u65e5\u5fd7\u6d41<\/b><\/p>\n

\u9664\u4e86\u5207\u5272\u548c\u5f52\u6863\u65e5\u5fd7\u6587\u4ef6\u5916\uff0crotatelogs\u8fd8\u652f\u6301\u5408\u5e76\u591a\u4e2a\u65e5\u5fd7\u6d41\u8f93\u51fa\u5230\u540c\u4e00\u4e2a\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u5408\u5e76\u6765\u81ea\u4e24\u4e2a\u4e0d\u540c\u8fdb\u7a0b\u7684\u65e5\u5fd7\u6d41\uff1a<\/p>\n

\n

\nrotatelogs -M\/var\/log\/access.log 86400\n<\/pre>\n<\/p>\n

\u8fd9\u6837\u5c31\u53ef\u4ee5\u5c06\u4e24\u4e2a\u8fdb\u7a0b\u7684\u65e5\u5fd7\u5408\u5e76\u8f93\u51fa\u5230\u540c\u4e00\u4e2aaccess.log\u6587\u4ef6\u4e2d\u3002<\/p>\n

8. rotatelogs\u547d\u4ee4\u7684\u9ad8\u7ea7\u7528\u6cd5\uff1a\u81ea\u5b9a\u4e49\u65e5\u5fd7\u5207\u5272\u6761\u4ef6<\/p>\n

\u901a\u8fc7\u4f7f\u7528\u81ea\u5b9a\u4e49\u811a\u672c\uff0c\u53ef\u4ee5\u5b9e\u73b0\u66f4\u7075\u6d3b\u7684\u65e5\u5fd7\u5207\u5272\u6761\u4ef6\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u901a\u8fc7\u81ea\u5b9a\u4e49\u811a\u672c\u6765\u5224\u65ad\u662f\u5426\u9700\u8981\u5207\u5272\u65e5\u5fd7\uff1a<\/p>\n

\n

\nrotatelogs -l\/var\/log\/access.log \/path\/to\/script\n<\/pre>\n<\/p>\n

\u5728\u811a\u672c\u4e2d\u53ef\u4ee5\u7f16\u5199\u903b\u8f91\u6765\u5224\u65ad\u662f\u5426\u9700\u8981\u5207\u5272\u65e5\u5fd7\uff0c\u5e76\u8fd4\u56de\u76f8\u5e94\u7684\u7ed3\u679c\u3002<\/p>\n

9. rotatelogs\u547d\u4ee4\u7684\u9ad8\u7ea7\u7528\u6cd5\uff1a\u7ed3\u5408\u5176\u4ed6\u5de5\u5177\u5b9e\u73b0\u66f4\u5f3a\u5927\u7684\u65e5\u5fd7\u7ba1\u7406\u529f\u80fd<\/p>\n

\u9664\u4e86\u5355\u72ec\u4f7f\u7528rotatelogs\u547d\u4ee4\u5916\uff0c\u8fd8\u53ef\u4ee5\u7ed3\u5408\u5176\u4ed6\u5de5\u5177\u6765\u5b9e\u73b0\u66f4\u5f3a\u5927\u7684\u65e5\u5fd7\u7ba1\u7406\u529f\u80fd\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528logrotate\u5de5\u5177\u6765\u5b9a\u671f\u6e05\u7406\u548c\u538b\u7f29\u5f52\u6863\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n

10. rotatelogs\u547d\u4ee4\u7684\u6ce8\u610f\u4e8b\u9879\u548c\u5e38\u89c1\u95ee\u9898\u89e3\u7b54<\/b><\/p>\n

\u5728\u4f7f\u7528rotatelogs\u547d\u4ee4\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n

-\u786e\u4fdd\u8f93\u51fa\u8def\u5f84\u53ef\u5199\uff1a\u786e\u4fdd\u6307\u5b9a\u7684\u8f93\u51fa\u8def\u5f84\u6709\u8db3\u591f\u7684\u6743\u9650\u8fdb\u884c\u5199\u64cd\u4f5c\u3002<\/p>\n

-\u907f\u514d\u6587\u4ef6\u540d\u91cd\u590d\uff1a\u5982\u679c\u591a\u4e2a\u8fdb\u7a0b\u540c\u65f6\u4f7f\u7528\u76f8\u540c\u7684\u8f93\u51fa\u8def\u5f84\u548c\u6587\u4ef6\u540d\u683c\u5f0f\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6587\u4ef6\u540d\u91cd\u590d\uff0c\u9700\u8981\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002<\/p>\n

-\u5b9a\u671f\u6e05\u7406\u5f52\u6863\u6587\u4ef6\uff1a\u5b9a\u671f\u6e05\u7406\u4e0d\u518d\u9700\u8981\u7684\u5f52\u6863\u65e5\u5fd7\u6587\u4ef6\uff0c\u4ee5\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n

\u4ee5\u4e0a\u662f\u5173\u4e8e\u5982\u4f55\u4f7f\u7528linux rotatelogs<\/strong>\u547d\u4ee4\u5b9e\u73b0\u65e5\u5fd7\u5207\u5272\u548c\u5f52\u6863\u7684\u4ecb\u7ecd\u3002\u901a\u8fc7\u5408\u7406\u914d\u7f6erotatelogs\u547d\u4ee4\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u548c\u67e5\u9605\u65e5\u5fd7\u6587\u4ef6\uff0c\u63d0\u9ad8\u7cfb\u7edf\u7a33\u5b9a\u6027\u548c\u6545\u969c\u6392\u67e5\u6548\u7387\u3002\u5e0c\u671b\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

linux rotatelogsrotatelogs\u547d\u4ee4\u7684\u9ad8\u7ea7\u7528\u6cd5\uff1a\u7ed3\u5408\u5176\u4ed6\u5de5\u5177\u5b9e\u73b0\u66f4\u5f3a\u5927\u7684\u65e5\u5fd7\u7ba1\u7406\u529f\u80fd\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528linux\u7cfb\u7edf\u4e2d\u7684rotatelogs\u547d\u4ee4\u6765\u5b9e\u73b0\u65e5\u5fd7\u5207\u5272\u548c\u5f52\u6863\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u901a\u8fc7\u81ea\u5b9a\u4e49\u811a\u672c\u6765\u5224\u65ad\u662f\u5426\u9700\u8981\u5207\u5272\u65e5\u5fd7\uff1a\u5728\u811a\u672c\u4e2d\u53ef\u4ee5\u7f16\u5199\u903b\u8f91\u6765\u5224\u65ad\u662f\u5426\u9700\u8981\u5207\u5272\u65e5\u5fd7\uff0c\u5e76\u8fd4\u56de\u76f8\u5e94\u7684\u7ed3\u679c\u3002rotatelogs\u547d\u4ee4\u7684\u9ad8\u7ea7\u7528\u6cd5\uff1a\u7ed3\u5408\u5176\u4ed6\u5de5\u5177\u5b9e\u73b0\u66f4\u5f3a\u5927\u7684\u65e5\u5fd7\u7ba1\u7406\u529f\u80fd<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-287935","post","type-post","status-publish","format-standard","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/287935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=287935"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/287935\/revisions"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=287935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=287935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=287935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}