{"id":64956,"date":"2025-05-03T08:30:49","date_gmt":"2025-05-03T00:30:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/64956\/"},"modified":"2025-05-03T08:30:49","modified_gmt":"2025-05-03T00:30:49","slug":"linux-%e7%b3%bb%e7%bb%9f%e4%b8%ad%ef%bc%8cnohup-log-%e6%96%87%e4%bb%b6%e8%b6%8a%e6%9d%a5%e8%b6%8a%e5%a4%a7%ef%bc%8c%e5%a6%82%e4%bd%95%e6%8e%a7%e5%88%b6%e5%85%b6%e4%bd%93%e7%a7%af%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/64956\/","title":{"rendered":"Linux \u7cfb\u7edf\u4e2d\uff0cnohup.log \u6587\u4ef6\u8d8a\u6765\u8d8a\u5927\uff0c\u5982\u4f55\u63a7\u5236\u5176\u4f53\u79ef\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173096409038760.jpg\" class=\"aligncenter\" title=\"Linux \u7cfb\u7edf\u4e2d\uff0cnohup.log \u6587\u4ef6\u8d8a\u6765\u8d8a\u5927\uff0c\u5982\u4f55\u63a7\u5236\u5176\u4f53\u79ef\uff1f\u63d2\u56fe\" alt=\"Linux \u7cfb\u7edf\u4e2d\uff0cnohup.log \u6587\u4ef6\u8d8a\u6765\u8d8a\u5927\uff0c\u5982\u4f55\u63a7\u5236\u5176\u4f53\u79ef\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>nohup.log \u6587\u4ef6\u5e9e\u5927\u5982\u5c71\uff0c\u5982\u4f55\u63a7\u5236\u4f53\u79ef\uff1f<\/strong><\/p>\n<p>\u5728  \u7cfb\u7edf\u4e2d\uff0cnohup.log \u6587\u4ef6\u7528\u4e8e\u5b58\u50a8\u4f7f\u7528 nohup \u547d\u4ee4\u6267\u884c\u7684\u8fdb\u7a0b\u4ea7\u751f\u7684\u63a7\u5236\u53f0\u8f93\u51fa\u3002\u4f46\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u5c24\u5176\u662f\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u6b64\u6587\u4ef6\u53ef\u80fd\u53d8\u5f97\u975e\u5e38\u5e9e\u5927\uff0c\u5360\u7528\u5927\u91cf\u670d\u52a1\u5668\u5b58\u50a8\u7a7a\u95f4\u3002\u56e0\u6b64\uff0c\u9650\u5236 nohup.out \u6587\u4ef6\u5927\u5c0f\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p>\u8981\u4e00\u52b3\u6c38\u9038\u5730\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u65e5\u5fd7\u8f6e\u8f6c\u5de5\u5177\uff0c\u5982 logrotate\u3002\u5b83\u5141\u8bb8\u60a8\u6839\u636e\u6587\u4ef6\u5927\u5c0f\u6216\u65f6\u95f4\u81ea\u52a8\u622a\u65ad\u548c\u538b\u7f29\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<p><strong>logrotate \u914d\u7f6e<\/strong><\/p>\n<p>\u8981\u4f7f\u7528 logrotate\uff0c\u8bf7\u521b\u5efa \/etc\/logrotate.conf \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>\/var\/log\/nohup.log {\n    daily\n    missingok\n    rotate 7\n    compress\n    delaycompress\n    notifempty\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u8868\u793a\uff1a<\/p>\n<ul>\n<li>\u6bcf\u5929\u5bf9 \/var\/log\/nohup.log \u8fdb\u884c\u8f6e\u6362<\/li>\n<li>\u5982\u679c nohup.log \u4e0d\u5b58\u5728\uff0c\u5219\u4e0d\u62a5\u9519<\/li>\n<li>\u6700\u591a\u4fdd\u7559 7 \u4e2a\u65e7\u65e5\u5fd7\u6587\u4ef6<\/li>\n<li>\u5c06\u65e7\u65e5\u5fd7\u6587\u4ef6\u538b\u7f29\u4e3a gzip \u538b\u7f29\u683c\u5f0f<\/li>\n<li>\u5728\u6587\u4ef6\u4e3a\u7a7a\u65f6\u5ef6\u8fdf\u538b\u7f29<\/li>\n<\/ul>\n<p>\u8bf7\u6839\u636e\u60a8\u7684\u5b9e\u9645\u60c5\u51b5\u8c03\u6574\u914d\u7f6e\u9009\u9879\uff0c\u4f8b\u5982\u4fdd\u7559\u5929\u6570\u548c\u538b\u7f29\u7b56\u7565\u3002<\/p>\n<p><strong>\u8bbe\u7f6ecrontab \u4f5c\u4e1a<\/strong><\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u8bbe\u7f6e\u4e00\u4e2a crontab \u4f5c\u4e1a\u4ee5\u5b9a\u671f\u8fd0\u884c logrotate\uff1a<\/p>\n<pre>0 5 * * * \/usr\/sbin\/logrotate \/etc\/logrotate.conf<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u8868\u793a\u6bcf\u5929\u65e9\u4e0a 5 \u70b9\u8fd0\u884c logrotate\u3002\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8c03\u6574\u9891\u7387\u3002<\/p>\n<p><strong>\u4f18\u70b9<\/strong><\/p>\n<p>\u4f7f\u7528 logrotate \u7684\u597d\u5904\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u81ea\u52a8\u5316\u65e5\u5fd7\u8f6e\u6362\uff0c\u65e0\u9700\u624b\u52a8\u5e72\u9884<\/li>\n<li>\u538b\u7f29\u65e7\u65e5\u5fd7\u6587\u4ef6\uff0c\u8282\u7701\u7a7a\u95f4<\/li>\n<li>\u786e\u4fdd\u4fdd\u7559\u6709\u9650\u6570\u91cf\u7684\u65e7\u65e5\u5fd7\u6587\u4ef6\u4ee5\u4f9b\u5ba1\u8ba1\u548c\u6545\u969c\u6392\u9664<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fLinux \u7cfb\u7edf\u4e2d\uff0cnohup.log \u6587\u4ef6\u8d8a\u6765\u8d8a\u5927\uff0c\u5982\u4f55\u63a7\u5236\u5176\u4f53\u79ef\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nohup.log \u6587\u4ef6\u5e9e\u5927\u5982\u5c71\uff0c\u5982\u4f55\u63a7\u5236\u4f53\u79ef\uff1f \u5728 \u7cfb\u7edf\u4e2d\uff0cnohup.log \u6587\u4ef6\u7528\u4e8e\u5b58\u50a8\u4f7f\u7528 nohup \u547d\u4ee4\u6267\u884c\u7684\u8fdb\u7a0b\u4ea7\u751f\u7684\u63a7\u5236\u53f0\u8f93\u51fa\u3002\u4f46\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u5c24\u5176\u662f\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u6b64\u6587\u4ef6\u53ef\u80fd\u53d8\u5f97\u975e\u5e38\u5e9e\u5927\uff0c\u5360\u7528\u5927\u91cf\u670d\u52a1\u5668\u5b58\u50a8\u7a7a\u95f4\u3002\u56e0\u6b64\uff0c\u9650\u5236 nohup.out \u6587\u4ef6\u5927\u5c0f\u81f3\u5173\u91cd\u8981\u3002 \u8981\u4e00\u52b3\u6c38\u9038\u5730\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u65e5\u5fd7\u8f6e\u8f6c\u5de5\u5177\uff0c\u5982 logrotate\u3002\u5b83\u5141\u8bb8\u60a8\u6839\u636e\u6587\u4ef6\u5927\u5c0f\u6216\u65f6\u95f4\u81ea\u52a8\u622a\u65ad\u548c\u538b\u7f29\u65e5\u5fd7\u6587\u4ef6\u3002 logrotate \u914d\u7f6e \u8981\u4f7f\u7528 logrotate\uff0c\u8bf7\u521b\u5efa \/etc\/logrotate.conf \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a \/var\/log\/nohup.log { daily missingok rotate 7 compress delaycompress notifempty } \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u8868\u793a\uff1a \u6bcf\u5929\u5bf9 \/var\/log\/nohup.log \u8fdb\u884c\u8f6e\u6362 \u5982\u679c nohup.log \u4e0d\u5b58\u5728\uff0c\u5219\u4e0d\u62a5\u9519 \u6700\u591a\u4fdd\u7559 7 \u4e2a\u65e7\u65e5\u5fd7\u6587\u4ef6 \u5c06\u65e7\u65e5\u5fd7\u6587\u4ef6\u538b\u7f29\u4e3a gzip \u538b\u7f29\u683c\u5f0f \u5728\u6587\u4ef6\u4e3a\u7a7a\u65f6\u5ef6\u8fdf\u538b\u7f29 \u8bf7\u6839\u636e\u60a8\u7684\u5b9e\u9645\u60c5\u51b5\u8c03\u6574\u914d\u7f6e\u9009\u9879\uff0c\u4f8b\u5982\u4fdd\u7559\u5929\u6570\u548c\u538b\u7f29\u7b56\u7565\u3002 \u8bbe\u7f6ecrontab \u4f5c\u4e1a \u63a5\u4e0b\u6765\uff0c\u8bbe\u7f6e\u4e00\u4e2a crontab \u4f5c\u4e1a\u4ee5\u5b9a\u671f\u8fd0\u884c logrotate\uff1a 0 5 * * * \/usr\/sbin\/logrotate [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-64956","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=64956"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64956\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=64956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=64956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=64956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}