{"id":63662,"date":"2025-04-29T12:33:00","date_gmt":"2025-04-29T04:33:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63662\/"},"modified":"2025-04-29T12:33:00","modified_gmt":"2025-04-29T04:33:00","slug":"linux%e7%b3%bb%e7%bb%9f%e6%97%a5%e5%bf%97%e6%80%8e%e4%b9%88%e6%9f%a5%e7%9c%8b-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63662\/","title":{"rendered":"linux\u7cfb\u7edf\u65e5\u5fd7\u600e\u4e48\u67e5\u770b"},"content":{"rendered":"<blockquote><p>\n  \u5982\u4f55\u67e5\u770b linux \u7cfb\u7edf\u65e5\u5fd7\uff1f\u4f7f\u7528 &#8220;journalctl&#8221; \u547d\u4ee4\u5b9e\u65f6\u67e5\u770b\u3001\u6309\u65f6\u95f4\u8fc7\u6ee4\u6216 \u6309\u5355\u4f4d\u548c\u6d88\u606f\u8fdb\u884c\u8fc7\u6ee4\u3002\u67e5\u770b\u5185\u6838\u73af\u7f13\u51b2\u533a\u7684\u65e9\u671f\u5f15\u5bfc\u6d88\u606f\uff0c\u4f7f\u7528 &#8220;dmesg&#8221; \u547d\u4ee4\u3002\u67e5\u770b\u5df2\u767b\u5f55\u7528\u6237\u7684\u5217\u8868\uff0c\u4f7f\u7528 &#8220;lastlog&#8221; \u547d\u4ee4\u3002\u4f7f\u7528 &#8220;tail -f \/var\/log\/syslog&#8221; \u6216 &#8220;less \/var\/log\/messages&#8221; \u4ee5\u5206\u9875\u65b9\u5f0f\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u7684\u5b9e\u65f6\u6d41\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/04\/2024060410032022440.jpg\" class=\"aligncenter\" title=\"linux\u7cfb\u7edf\u65e5\u5fd7\u600e\u4e48\u67e5\u770b\u63d2\u56fe\" alt=\"linux\u7cfb\u7edf\u65e5\u5fd7\u600e\u4e48\u67e5\u770b\u63d2\u56fe\" \/><\/p>\n<p><strong>Linux \u7cfb\u7edf\u65e5\u5fd7\u67e5\u770b\u6307\u5357<\/strong><\/p>\n<p>\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u65e5\u5fd7\u6587\u4ef6\u8bb0\u5f55\u4e86\u7cfb\u7edf\u4e8b\u4ef6\u3001\u9519\u8bef\u548c\u64cd\u4f5c\u3002\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u5bf9\u4e8e\u6545\u969c\u6392\u9664\u548c\u7cfb\u7edf\u7ef4\u62a4\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b Linux \u7cfb\u7edf\u65e5\u5fd7<\/strong><\/p>\n<p>\u6700\u5e38\u7528\u7684\u547d\u4ee4\u662f journalctl\uff1a<\/p>\n<ul>\n<li> <strong>\u5b9e\u65f6\u67e5\u770b\u65e5\u5fd7\uff1a<\/strong> journalctl -f<\/li>\n<li> <strong>\u6309\u65f6\u95f4\u67e5\u770b\u65e5\u5fd7\uff1a<\/strong> journalctl &#8211;since &#8220;timestamp&#8221;\uff08\u4f8b\u5982 journalctl &#8211;since &#8220;2023-03-08 16:00:00&#8243;\uff09<\/li>\n<li> <strong>\u5355\u4f4d\u8fc7\u6ee4\uff1a<\/strong> journalctl | grep unit_name\uff08\u4f8b\u5982 journalctl | grep sshd\uff09<\/li>\n<li> <strong>\u6d88\u606f\u8fc7\u6ee4\uff1a<\/strong> journalctl | grep &#8220;error message&#8221;<\/li>\n<\/ul>\n<p><strong>\u5176\u4ed6\u6709\u7528\u7684\u547d\u4ee4<\/strong><\/p>\n<ul>\n<li> <strong>dmesg\uff1a<\/strong> \u67e5\u770b\u5185\u6838\u73af\u7f13\u51b2\u533a\u4e2d\u7684\u65e9\u671f\u5f15\u5bfc\u6d88\u606f\u3002<\/li>\n<li> <strong>lastlog\uff1a<\/strong> \u67e5\u770b\u5df2\u767b\u5f55\u7528\u6237\u7684\u5217\u8868\u3002<\/li>\n<li> <strong>tail -f \/var\/log\/syslog\uff1a<\/strong> \u67e5\u770b\u7cfb\u7edf\u65e5\u5fd7\u6587\u4ef6\u7684\u5b9e\u65f6\u6d41\u3002<\/li>\n<li> <strong>less \/var\/log\/messages\uff1a<\/strong> \u4ee5\u5206\u9875\u65b9\u5f0f\u67e5\u770b\u6d88\u606f\u65e5\u5fd7\u3002<\/li>\n<\/ul>\n<p><strong>\u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e<\/strong><\/p>\n<p>Linux \u7cfb\u7edf\u7684\u65e5\u5fd7\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e\u4ee5\u4e0b\u76ee\u5f55\uff1a<\/p>\n<ul>\n<li>\/var\/log\uff1a\u4e3b\u8981\u7684\u65e5\u5fd7\u6587\u4ef6\u76ee\u5f55\u3002<\/li>\n<li>\/var\/log\/messages\uff1a\u7cfb\u7edf\u6d88\u606f\u65e5\u5fd7\u3002<\/li>\n<li>\/var\/log\/kern.log\uff1a\u5185\u6838\u65e5\u5fd7\u3002<\/li>\n<li>\/var\/log\/auth.log\uff1a\u6388\u6743\u548c\u8eab\u4efd\u9a8c\u8bc1\u65e5\u5fd7\u3002<\/li>\n<li>\/var\/log\/syslog\uff1a\u7cfb\u7edf\u65e5\u5fd7\u7684\u7b26\u53f7\u94fe\u63a5\uff0c\u6307\u5411 \/var\/log\/messages\u3002<\/li>\n<\/ul>\n<p><strong>\u9ad8\u7ea7\u9009\u9879<\/strong><\/p>\n<ul>\n<li> <strong>\u4f7f\u7528\u65e5\u5fd7\u7ea7\u522b\uff1a<\/strong> journalctl -l\uff08\u4f8b\u5982 journalctl -l err\uff09<\/li>\n<li> <strong>\u6309 pid \u8fc7\u6ee4\uff1a<\/strong> journalctl _PID=1234<\/li>\n<li> <strong>\u7f13\u51b2\u533a\u6eda\u52a8\uff1a<\/strong> journalctl &#8211;rotate<\/li>\n<li> <strong>\u6e05\u9664\u65e5\u5fd7\uff1a<\/strong> journalctl &#8211;vacuum-time=&#8221;2 weeks&#8221;<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7cfb\u7edf\u65e5\u5fd7\u600e\u4e48\u67e5\u770b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u67e5\u770b linux \u7cfb\u7edf\u65e5\u5fd7\uff1f\u4f7f\u7528 &#8220;journalctl&#8221; \u547d\u4ee4\u5b9e\u65f6\u67e5\u770b\u3001\u6309\u65f6\u95f4\u8fc7\u6ee4\u6216 \u6309\u5355\u4f4d\u548c\u6d88\u606f\u8fdb\u884c\u8fc7\u6ee4\u3002\u67e5\u770b\u5185\u6838\u73af\u7f13\u51b2\u533a\u7684\u65e9\u671f\u5f15\u5bfc\u6d88\u606f\uff0c\u4f7f\u7528 &#8220;dmesg&#8221; \u547d\u4ee4\u3002\u67e5\u770b\u5df2\u767b\u5f55\u7528\u6237\u7684\u5217\u8868\uff0c\u4f7f\u7528 &#8220;lastlog&#8221; \u547d\u4ee4\u3002\u4f7f\u7528 &#8220;tail -f \/var\/log\/syslog&#8221; \u6216 &#8220;less \/var\/log\/messages&#8221; \u4ee5\u5206\u9875\u65b9\u5f0f\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u7684\u5b9e\u65f6\u6d41\u3002 Linux \u7cfb\u7edf\u65e5\u5fd7\u67e5\u770b\u6307\u5357 \u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u65e5\u5fd7\u6587\u4ef6\u8bb0\u5f55\u4e86\u7cfb\u7edf\u4e8b\u4ef6\u3001\u9519\u8bef\u548c\u64cd\u4f5c\u3002\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u5bf9\u4e8e\u6545\u969c\u6392\u9664\u548c\u7cfb\u7edf\u7ef4\u62a4\u975e\u5e38\u91cd\u8981\u3002 \u5982\u4f55\u67e5\u770b Linux \u7cfb\u7edf\u65e5\u5fd7 \u6700\u5e38\u7528\u7684\u547d\u4ee4\u662f journalctl\uff1a \u5b9e\u65f6\u67e5\u770b\u65e5\u5fd7\uff1a journalctl -f \u6309\u65f6\u95f4\u67e5\u770b\u65e5\u5fd7\uff1a journalctl &#8211;since &#8220;timestamp&#8221;\uff08\u4f8b\u5982 journalctl &#8211;since &#8220;2023-03-08 16:00:00&#8243;\uff09 \u5355\u4f4d\u8fc7\u6ee4\uff1a journalctl | grep unit_name\uff08\u4f8b\u5982 journalctl | grep sshd\uff09 \u6d88\u606f\u8fc7\u6ee4\uff1a journalctl | grep &#8220;error message&#8221; \u5176\u4ed6\u6709\u7528\u7684\u547d\u4ee4 dmesg\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63662","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63662","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=63662"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63662\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}