{"id":201562,"date":"2020-09-30T09:09:14","date_gmt":"2020-09-30T01:09:14","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=201562"},"modified":"2020-09-23T14:10:01","modified_gmt":"2020-09-23T06:10:01","slug":"linux-log-solve","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-log-solve.html","title":{"rendered":"Linux\u4e0b\u65e5\u5fd7\u6587\u4ef6\u8fc7\u5927\u7684\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5f88\u591aLinux\u670d\u52a1\u5668\u91cc\u7684\u5e94\u7528\u7a0b\u5e8f\u90fd\u662f\u65e0\u95f4\u65ad\u7684\u8f93\u51fa\u65e5\u5fd7\uff0c\u8fd9\u5bf9\u4e8e\u670d\u52a1\u5668\u7684\u786c\u76d8\u662f\u4e00\u4e2a\u5f88\u5927\u7684\u8003\u9a8c<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u6211\u4eec\u90fd\u77e5\u9053\uff0c\u65e5\u5fd7\u5bf9\u4e8e\u6211\u4eec\u800c\u8a00\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u4e00\u91cf\u5e94\u7528\u7a0b\u5e8f\u51fa\u73b0bug\uff0c\u6216\u8005\u670d\u52a1\u5668\u5b95\u673a\uff0c\u6211\u4eec\u5fc5\u987b\u901a\u8fc7\u65e5\u5fd7\u6587\u4ef6\u6765\u8fdb\u884cdebug\u6216\u8fdb\u4e00\u6b65\u5206\u6790\u3002\u6240\u4ee5\uff0c\u65e5\u5fd7\u6587\u4ef6\u4e0d\u80fd\u7b80\u5355\u7684\u4e00\u5220\u4e86\u4e4b\u3002<\/p>\n

\u8fd9\u65f6\uff0c\u6211\u4eec\u60f3\u5230\uff0c\u5982\u679c\u80fd\u5c06\u65e5\u5fd7\u6587\u4ef6\u5207\u5206\u8be5\u591a\u597d\uff0c\u8fd9\u6837\u6211\u4eec\u53ef\u4ee5\u7559\u4e0b\u91cd\u8981\u7684\u65e5\u5fd7\uff0c\u800c\u5220\u6389\u4e0d\u5fc5\u8981\u7684\u65e5\u5fd7\u3002\u4e0b\u9762\u826f\u8bb8\u5c31\u6765\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u79cd\u65b9\u6cd5\u3002<\/p>\n

\u6211\u4eec\u53ef\u4ee5\u6bcf\u5929\u90fd\u8fdb\u884c\u5207\u5206\u65e5\u5fd7\u7684\u64cd\u4f5c\uff0c\u90a3\u8981\u8fd9\u6837\u7684\u8bdd\uff0c\u4e3a\u4e86\u907f\u514d\u6df7\u6dc6\uff0c\u6211\u4eec\u5207\u5206\u51fa\u6765\u7684\u65e5\u5fd7\u90fd\u5e94\u8be5\u5e26\u4e0a\u65e5\u671f\u3002\u5f53\u7136\u65e5\u671f\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u8bed\u53e5\u83b7\u53d6\uff1a<\/p>\n

\r\ncurrent_date=`date -d \"-1 day\" \"+%Y%m%d\"` \r\n<\/pre>\n

date -d \"-1 day\"\u8868\u793a\u83b7\u53d6\u524d\u4e00\u5929\u7684\u65e5\u671f\uff0c\u5c31\u662f\u8bf4\u6211\u4eec\u4eca\u5929\u64cd\u4f5c\u7684\u8bdd\u662f\u5207\u5272\u6628\u5929\u7684\u65e5\u5fd7\u3002+%Y%m%d\u662f\u5177\u4f53\u7684\u65e5\u671f\u683c\u5f0f\uff0c\u4e5f\u5c31\u662f\u5e74\u6708\u65e5\u683c\u5f0f\uff0c\u6bd4\u5982\uff1a20181005\u3002<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u518d\u5207\u5272\u65e5\u5fd7\u3002<\/p>\n

\r\nsplit  -b 65535000 -d -a 4  myout.txt  .\/log\/log_${current_date}_ \r\n<\/pre>\n

\u5176\u4e2d\uff0c65535000\u662f60M\uff0c\u4e5f\u5c31\u662f\u65e5\u5fd7\u6587\u4ef6\u630960M\u5927\u5c0f\u8fdb\u884c\u5207\u5272\uff0c\u53ef\u81ea\u5b9a\u4e49\u5927\u5c0f\u3002-d -a 4\u8868\u793a\u6587\u4ef6\u540e\u7f00\u662f4\u4f4d\u3002\u6211\u4eec\u5c06\u6587\u4ef6\u5207\u5272\u540e\u8981\u6309\u6b21\u5e8f\u8fdb\u884c\u7f16\u53f7\uff0c\u6bd4\u59820000\uff0c0001\uff0c0002\u2026\u2026\u8fd9\u4e2a4\u5c31\u4ee3\u8868\u7f16\u53f7\u7684\u4f4d\u6570\u3002<\/p>\n

\u518d\u4e4b\u540e\u7684.\/log\/log${current_date}\u5c31\u662f\u5207\u5272\u540e\u65e5\u5fd7\u6587\u4ef6\u7684\u524d\u7f00\uff0c\u91cc\u9762\u5c31\u5e26\u5165\u4e86\u5f53\u524d\u65e5\u671f\u3002\u6240\u4ee5\uff0c\u6700\u7ec8\u7684\u8f93\u51fa\u683c\u5f0f\u7c7b\u4f3c\u4e8e\uff1alog_20181005_0001\u3002<\/p>\n

\u65e5\u5fd7\u6587\u4ef6\u5207\u5272\u5b8c\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u5c06\u65e5\u5fd7\u6587\u4ef6\u5220\u9664\u4e86\uff0c\u5426\u5219\u5c31\u5931\u53bb\u5207\u5272\u6587\u4ef6\u7684\u610f\u4e49\u4e86\u3002\u5220\u9664\u7684\u65b9\u6cd5\u53ef\u4ee5\u7528\u4ee5\u4e0b\u65b9\u5f0f\uff1a<\/p>\n

\r\ncat \/dev\/null > nohup.out \r\n<\/pre>\n

\u5c06\u4ee5\u4e0a\u8fd9\u4e9b\u547d\u4ee4\u5199\u5728\u4e00\u4e2a\u811a\u672c\u91cc\uff0c\u6bcf\u5929\u8fd0\u884c\u5b83\uff0c\u5c31\u53ef\u4ee5\u5c06\u65e5\u5fd7\u6587\u4ef6\u5207\u5272\u6210\u82e5\u5e72\u5206\uff0c\u4fbf\u4e8e\u6211\u4eec\u6392\u67e5\u3002\u5b8c\u6574\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

\r\n#!\/bin\/bash \r\ncurrent_date=`date -d \"-1 day\" \"+%Y%m%d\"` \r\nsplit -b 65535000 -d -a 4 \/home\/alvin\/myout.txt   \/home\/alvin\/log\/log_${current_date}_ \r\ncat \/dev\/null > nohup.out \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u5f88\u591aLinux\u670d\u52a1\u5668\u91cc\u7684\u5e94\u7528\u7a0b\u5e8f\u90fd\u662f\u65e0\u95f4\u65ad\u7684\u8f93\u51fa\u65e5\u5fd7\uff0c\u8fd9\u5bf9\u4e8e\u670d\u52a1\u5668\u7684\u786c\u76d8\u662f\u4e00\u4e2a\u5f88\u5927\u7684\u8003\u9a8c<\/p>\n","protected":false},"author":370,"featured_media":87721,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-201562","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/201562","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\/370"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=201562"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/201562\/revisions"}],"predecessor-version":[{"id":201564,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/201562\/revisions\/201564"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/87721"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=201562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=201562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=201562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}