{"id":287516,"date":"2023-11-18T04:04:09","date_gmt":"2023-11-17T20:04:09","guid":{"rendered":"https:\/\/lrxjmw.cn\/lgjsjtzddchj.html"},"modified":"2023-11-18T04:04:09","modified_gmt":"2023-11-17T20:04:09","slug":"lgjsjtzddchj","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lgjsjtzddchj.html","title":{"rendered":"Linux\u5173\u673a\u65f6\u95f4\u592a\u957f\u7684\u8c03\u67e5\u548c\u89e3\u51b3\u7684\u65b9\u6cd5\uff08\u56fe\u6587\uff09"},"content":{"rendered":"

\u4f60\u662f\u5426\u5f53\u521d\u9047\u89c1\u8fc7Linux<\/a>\u7cfb\u7edf<\/a>\u7ec8\u7aef\u5361\u987f\u3001\u5173\u673a\u6162\u7b49\u95ee\u9898\uff1f\u8fd9\u79cd\u95ee\u9898\u9664\u4e86\u5f71\u54cd\u4f7f\u7528\u4f53\u9a8c\uff0c\u8fd8\u53ef\u80fd\u5f71\u54cd\u5de5\u4f5c\u6548\u7387\u548c\u7cfb\u7edf\u7a33\u5b9a\u6027\u3002\u672c\u6587\u5c06\u4ecb\u7ecdLinux\u7cfb\u7edf\u4f18\u5316\u7684\u4e00\u4e9b\u6280\u5de7\uff0c\u5e2e\u52a9\u4f60\u63d0\u9ad8\u7cfb\u7edf\u6027\u80fd\uff0c\u9632\u6b62\u5361\u987f\u548c\u957f\u65f6\u95f4\u6b7b\u673a\u7684\u95ee\u9898\u3002<\/p>\n

\u6211\u5e0c\u671b\u4f60\u5bf9sigterm\u548csigkill\u7684\u6982\u5ff5\u6709\u4e00\u70b9\u719f\u6089\u3002<\/p>\n

\u5f53\u4f60\u5173\u6389Linux\u7cfb\u7edf\u65f6\uff0c\u5b83\u4f1a\u53d1\u9001\u4e2d\u6b62\u8baf\u53f7(sigterm)\uff0c\u5e76\u793c\u8c8c\u5730\u8981\u6c42\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u505c\u6b62\u3002\u6709\u4e9b\u8fdb\u7a0b\u4e0d\u7b26\u5408\u8be5\u884c\u4e3a\uff0c\u5b83\u4eec\u4f1a\u5ffd\u89c6\u4e2d\u6b62\u8baf\u53f7\u5e76\u7ee7\u7eed\u8fd0\u884c\u3002<\/p>\n

Linux\u6b7b\u673a\u65f6\u95f4\u592a\u957f\u7684\u8c03\u67e5\u548c\u89e3\u51b3\u7684\u65b9\u5f0fLinux\u6b7b\u673a\u65f6\u95f4\u592a\u957f\u7684\u8c03\u67e5\u548c\u89e3\u51b3\u7684\u65b9\u5f0f<\/p>\n

\u8fd9\u53ef\u80fd\u4f1a\u9020\u6210\u6b7b\u673a\u8fc7\u7a0b\u7684\u5ef6\u540e\uff0c\u7531\u4e8e\u4f60\u7684\u7cfb\u7edf\u4f1a\u5728\u4e00\u4e2a\u9884\u5b9a\u4e49\u7684\u65f6\u95f4\u6bb5\u5185\u7b49\u5f85\u8fd0\u884c\u7684\u8fdb\u7a0b\u505c\u6b62\u3002\u5728\u8fd9\u4e2a\u65f6\u95f4\u6bb5\u4ee5\u540e\uff0c\u5b83\u4f1a\u53d1\u9001kill\u8baf\u53f7\u6765\u5f3a\u5236\u505c\u6b62\u6240\u6709\u5269\u4f59\u7684\u8fd0\u884c\u8fdb\u7a0b\u5e76\u5173\u6389\u7cfb\u7edf\u3002<\/p>\n

\u4e8b\u5b9e\u4e0a\uff0c\u5728\u4e2a\u522b\u60c5\u51b5\u4e0b\uff0c\u4f60\u4f1a\u5728\u84dd\u5c4f\u4e0a\u770b\u89c1\u4e00\u4e2a\u7c7b\u4f3c\u201castopjobisrunning\u201d\u7684\u4fe1\u606f\u3002<\/p>\n

\u5047\u5982\u4f60\u7684\u7cfb\u7edf\u5173\u6389\u65f6\u95f4\u592a\u957f\uff0c\u4f60\u53ef\u4ee5\u505a\u4ee5\u4e0b\u5de5\u4f5c\uff1a<\/p>\n

\u68c0\u6d4b\u90a3\u4e2a\u8fdb\u7a0b\/\u670d\u52a1\u5386\u65f6\u8fc7\u957f\uff0c\u4ee5\u53ca\u4f60\u662f\u5426\u80fd\u5220\u6389\u6216\u91cd\u65b0\u914d\u7f6e\u5b83\uff0c\u4f7f\u5176\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n

linux\u7cfb\u7edf\u53d8\u6162_linux\u7cfb\u7edf\u53d8\u6162_linux\u7cfb\u7edf\u53d8\u6162<\/p>\n

\u4fee\u6539\u7cfb\u7edf\u5f3a\u5236\u505c\u6b62\u8fd0\u884c\u8fdb\u7a0b\u524d\u7684\u9ed8\u8ba4\u7b49\u5f85\u65f6\u95f4\u3002(\u5feb\u901f\u800c\u4e0d\u9ad8\u8d35\u7684\u5f62\u5f0f)<\/p>\n

\u6211\u7684\u64cd\u4f5c\u7cfb\u7edf\u662f\u4f7f\u7528systemd\u7684Ubuntu\u3002\u8fd9\u513f\u7684\u547d\u4ee4<\/a>\u548c\u6b65\u9aa4\u9002\u7528\u4e8e\u4efb\u4f55\u4f7f\u7528systemd\u7684Linux\u53d1\u884c\u7248(\u5927\u591a\u6570\u53d1\u884c\u7248\u90fd\u662f\u8fd9\u6837)\u3002<\/p>\n

\u68c0\u6d4b\u4ec0\u4e48\u8fdb\u7a0b\u4f1a\u9020\u6210Linux\u7684\u957f\u65f6\u95f4\u6b7b\u673a<\/p>\n

\u5047\u5982\u4f60\u60f3\u627e\u51fa\u95ee\u9898\u6240\u5728\uff0c\u4f60\u5e94\u5f53\u68c0\u6d4b\u5148\u524d\u6b7b\u673a\u65f6\u53d1\u751f\u4e86\u54ea\u4e9b\u3002\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u6765\u83b7\u5f97\u201c\u6211\u6653\u5f97\u4f60\u4e0a\u4e2a\u4f1a\u8bdd\u505a\u4e86\u54ea\u4e9b\u201d(IKnowWhatYouDidLastSummer\u7684\u53cc\u5173\u8bed)\u7684\u529b\u91cf\u3002<\/p>\n

\n

journalctl\u00a0-rb\u00a0-1\u00a0\n<\/code><\/pre>\n<\/p>\n

journalctl\u547d\u4ee4\u80fd\u8ba9\u4f60\u8bfb\u53d6\u7cfb\u7edf\u65e5\u5fd7\u3002\u4f7f\u7528\u9009\u9879-b-1\u53ef\u4ee5\u8fc7\u6ee4\u6700\u540e\u4e00\u6b21\u542f\u52a8\u4f1a\u8bdd\u7684\u65e5\u5fd7\u3002\u4f7f\u7528\u9009\u9879-r\u65f6\uff0c\u65e5\u5fd7\u5c06\u6309\u65f6\u95f4\u9006\u5e8f\u663e\u793a\u3002<\/p>\n

\u6362\u53e5\u8bdd\u8bf4\uff0cjournalctl-rb-1\u547d\u4ee4\u5c06\u663e\u793a\u6700\u540e\u4e00\u6b21\u5173\u6389Linux\u7cfb\u7edf\u4e4b\u524d\u7684\u7cfb\u7edf\u65e5\u5fd7\u3002\u8fd9\u513f\u5c31\u662f\u4f60\u987b\u8981\u5256\u6790Linux\u7cfb\u7edf\u957f\u65f6\u95f4\u6b7b\u673a\u95ee\u9898\u7684\u5730\u65b9\u3002<\/p>\n

\u6ca1\u6709journal\u65e5\u5fd7?\u4e0b\u8fb9\u662f\u4f60\u5e94\u5f53\u505a\u7684<\/p>\n

\u5047\u5982\u6ca1\u6709journal\u65e5\u5fd7\uff0c\u8bf7\u786e\u8ba4\u4f60\u7684\u53d1\u884c\u7248\u662f\u5426\u4f7f\u7528systemd\u3002<\/p>\n

\u867d\u7136\u5728\u4e00\u4e9b\u4f7f\u7528systemd\u7684Linux\u53d1\u884c\u7248\u4e0a\uff0cjournal\u65e5\u5fd7\u4e5f\u6ca1\u6709\u88ab\u9ed8\u8ba4\u6fc0\u6d3b\u3002<\/p>\n

\u8bf7\u786e\u8ba4\/var\/log\/journal\u662f\u5426\u5b58\u5728\u3002\u5018\u82e5\u4e0d\u5b58\u5728linux vi\u547d\u4ee4\uff0c\u8bf7\u521b\u5efa\u5b83\uff1a<\/p>\n

\n

sudo\u00a0mkdir\u00a0\/var\/log<\/span>\/journal\u00a0\n<\/code><\/pre>\n<\/p>\n

\u4f60\u8fd8\u5e94\u5f53\u68c0\u6d4b\/etc\/systemd\/journald.conf\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u5e76\u786e\u4fddStorage\u7684\u503c\u88ab\u8bbe\u7f6e\u4e3a\u624b\u52a8(auto)\u6216\u6301\u4e45(persistent)\u3002<\/p>\n

\u4f60\u662f\u5426\u5728\u65e5\u5fd7\u4e2d\u53d1\u89c9\u53ef\u7591\u7684\u4e1c\u897f?\u662f\u5426\u6709\u4e00\u4e2a\u8fdb\u7a0b\/\u670d\u52a1\u62d2\u7edd\u505c\u6b62?\u5047\u5982\u662f\uff0c\u8c03\u67e5\u4e00\u4e0b\u662f\u5426\u53ef\u4ee5\u5728\u6ca1\u6709\u526f\u4f5c\u7528\u7684\u60c5\u51b5\u4e0b\u5220\u6389\u5b83\uff0c\u6216\u5219\u662f\u5426\u53ef\u4ee5\u91cd\u65b0\u914d\u7f6e\u5b83\u3002\u8bf7\u4e0d\u8981\u5728\u8fd9\u513f\u76f2\u76ee\u5730\u53bb\u5220\u6389\u4e1c\u897f\u3002\u4f60\u5e94\u5f53\u5bf9\u8fd9\u4e2a\u8fdb\u7a0b\u6709\u6240\u4e86\u89e3\u3002<\/p>\n

\u901a\u8fc7\u964d\u4f4e\u9ed8\u8ba4\u505c\u6b62\u8d85\u65f6\u6765\u63a8\u52a8Linux\u4e2d\u7684\u6b7b\u673a\u901f\u7387(\u5feb\u901f\u4fee\u8865)<\/p>\n

\u6b7b\u673a\u7684\u9ed8\u8ba4\u7b49\u5f85\u65f6\u95f4\u4e00\u822c\u8bbe\u7f6e\u4e3a90\u79d2\u3002\u5728\u8fd9\u4e2a\u65f6\u95f4\u4ee5\u540elinux\u7cfb\u7edf\u53d8\u6162<\/strong>\uff0c\u4f60\u7684\u7cfb\u7edf\u4f1a\u5c1d\u8bd5\u5f3a\u5236\u505c\u6b62\u670d\u52a1\u3002<\/p>\n

\u5047\u5982\u4f60\u60f3\u8ba9\u4f60\u7684Linux\u7cfb\u7edf\u5feb\u901f\u5173\u6389\uff0c\u4f60\u53ef\u4ee5\u6539\u53d8\u8fd9\u4e2a\u7b49\u5f85\u65f6\u95f4\u3002<\/p>\n

\u4f60\u53ef\u4ee5\u5728\u5750\u843d\/etc\/systemd\/system.conf\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u627e\u5230\u6240\u6709\u7684systemd\u8bbe\u7f6e\u3002\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u5e94\u5f53\u6709\u597d\u591a\u4ee5#\u5f00\u5934\u7684\u884c\u3002\u5b83\u4eec\u4ee3\u8868\u4e86\u6587\u4ef6\u4e2d\u5404\u6761\u76ee\u7684\u9ed8\u8ba4\u503c\u3002<\/p>\n

\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u6700\u597d\u5148\u590d\u5236\u4e00\u4efd\u539f\u59cb\u6587\u4ef6\u3002<\/p>\n

\n

sudo\u00a0cp\u00a0\/etc\/systemd\/system.conf\u00a0\/etc\/systemd\/system.conf.orig\u00a0\n<\/code><\/pre>\n<\/p>\n

\u5728\u8fd9\u513f\u627e\u5bfbDefaultTimeoutStopSec\u3002\u5b83\u53ef\u80fd\u88ab\u8bbe\u7f6e\u4e3a90\u79d2\u3002<\/p>\n

\n

#DefaultTimeoutStopSec=90s\u00a0<\/span>\n<\/code><\/pre>\n<\/p>\n

\u4f60\u5f97\u628a\u8fd9\u4e2a\u503c\u6539\u6210\u66f4\u4fbf\u6377\u7684\uff0c\u4f8b\u59825\u79d2\u621610\u79d2\u3002<\/p>\n

\n

DefaultTimeoutStopSec=5s\u00a0\n<\/code><\/pre>\n<\/p>\n

\u5047\u5982\u4f60\u4e0d\u6653\u5f97\u600e\u6837\u5728\u7ec8\u7aef\u4e2d\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u5728\u7cfb\u7edf\u9ed8\u8ba4\u7684\u6587\u672c\u7f16\u8f91\u5668(\u5982Gedit)\u4e2d\u6253\u5f00\u6587\u4ef6\u8fdb\u884c\u7f16\u8f91\uff1a<\/p>\n

\n

sudo\u00a0xdg-open\u00a0\/etc\/systemd\/system.conf\u00a0\n<\/code><\/pre>\n<\/p>\n

Linux\u6b7b\u673a\u65f6\u95f4\u592a\u957f\u7684\u8c03\u67e5\u548c\u89e3\u51b3\u7684\u65b9\u5f0fLinux\u6b7b\u673a\u65f6\u95f4\u592a\u957f\u7684\u8c03\u67e5\u548c\u89e3\u51b3\u7684\u65b9\u5f0f<\/p>\n

\u4e0d\u8981\u5fd8\u6389\u5220\u6389DefaultTimeoutStopSec\u524d\u7684#\u53f7\u3002\u4fdd\u5b58\u6587\u4ef6\u5e76\u91cd\u542f\u7cfb\u7edf\u3002<\/p>\n

\u8fd9\u5c06\u5e2e\u52a9\u4f60\u964d\u4f4eLinux\u7cfb\u7edf\u7684\u6b7b\u673a\u5ef6\u540e\u3002<\/p>\n

\u770b\u95e8\u72d7\u95ee\u9898!<\/p>\n

Linux\u6709\u4e00\u4e2a\u540d\u4e3a\u770b\u95e8\u72d7\u7684\u6a21\u5757\uff0c\u7528\u4e8e\u76d1\u63a7\u4e2a\u522b\u670d\u52a1\u662f\u5426\u5728\u8fd0\u884c\u3002\u5b83\u53ef\u4ee5\u88ab\u914d\u7f6e\u4e3a\u5728\u7cfb\u7edf\u56e0\u8f6f\u4ef6\u9519\u8bef\u800c\u6302\u8d77\u65f6\u624b\u52a8\u91cd\u542f\u7cfb\u7edf\u3002<\/p>\n

\u5728\u684c\u9762\u7cfb\u7edf\u4e0a\u4f7f\u7528\u770b\u95e8\u72d7\u662f\u4e0d\u5e38\u89c1\u7684\uff0c\u7531\u4e8e\u4f60\u53ef\u4ee5\u81ea\u52a8\u5173\u6389\u6216\u91cd\u542f\u7cfb\u7edf\u3002\u5b83\u5e38\u5e38\u88ab\u7528\u4e8e\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n

\u9996\u5148\u68c0\u6d4b\u770b\u95e8\u72d7\u662f\u5426\u5728\u8fd0\u884c\uff1a<\/p>\n

\n

ps\u00a0-af\u00a0|\u00a0grep\u00a0watch*\u00a0\n<\/code><\/pre>\n<\/p>\n

\u5047\u5982\u4f60\u7684\u7cfb\u7edf\u6b63\u5728\u8fd0\u884c\u770b\u95e8\u72d7\uff0c\u4f60\u53ef\u4ee5\u5728systemd\u914d\u7f6e\u6587\u4ef6\/etc\/systemd\/system.conf\u4e0a\u5c06ShutdownWatchdogSec\u7684\u503c\u4ece10\u5206\u949f\u6539\u4e3a\u66f4\u4f4e\u7684\u503c\u3002<\/p>\n

\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u4f60\u5df2\u7136\u4e86\u89e3\u4e86\u4e00\u4e9bLinux\u7cfb\u7edf\u4f18\u5316\u7684\u65b9\u5f0f\uff0c\u5305\u62ec\u7981\u7528\u670d\u52a1\u3001\u8c03\u6574\u5185\u6838\u53c2\u6570\u3001\u5347\u7ea7\u9a71\u52a8\u7a0b\u5e8f\u3001\u6e05\u7406\u5783\u573e\u6587\u4ef6\u7b49\u7b49\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4f60\u53ef\u4ee5\u63d0\u9ad8\u7cfb\u7edf\u6027\u80fd\uff0c\u9632\u6b62\u7ec8\u7aef\u5361\u987f\u3001\u5173\u673a\u6162\u7b49\u95ee\u9898\u3002\u5176\u5b9e\uff0c\u5bf9\u4e8e\u4e0d\u540c\u7684\u7cfb\u7edf\u548c\u4f7f\u7528\u573a\u666flinux\u7cfb\u7edf\u53d8\u6162<\/strong>\uff0c\u987b\u8981\u91c7\u7528\u4e0d\u540c\u7684\u4f18\u5316\u65b9\u5f0f\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u4f60\u53ef\u4ee5\u6309\u7167\u5177\u4f53\u60c5\u51b5\u9009\u62e9\u5408\u9002\u7684\u4f18\u5316\u7b56\u7565linux\u7cfb\u7edfiso\u4e0b\u8f7d\uff0c\u5e76\u6309\u7167\u5b9e\u9645\u7597\u6548\u8c03\u6574\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4f60\u662f\u5426\u66fe\u7ecf\u9047\u5230\u8fc7Linux\u7cfb\u7edf\u7ec8\u7aef\u5361\u987f\u3001\u5173\u673a\u6162\u7b49\u95ee\u9898\uff1f\u672c\u6587\u5c06\u4ecb\u7ecdLinux\u7cfb\u7edf\u4f18\u5316\u7684\u4e00\u4e9b\u65b9\u6cd5\uff0c\u5e2e\u52a9\u4f60\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\uff0c\u907f\u514d\u5361\u987f\u548c\u957f\u65f6\u95f4\u5173\u673a\u7684\u95ee\u9898\u3002\u7cfb\u7edf\u5feb\u901f\u5173\u95ed\uff0c\u4f60\u53ef\u4ee5\u6539\u53d8\u8fd9\u4e2a\u7b49\u5f85\u65f6\u95f4\u3002\u5b83\u53ef\u4ee5\u88ab\u914d\u7f6e\u4e3a\u5728\u7cfb\u7edf\u56e0\u8f6f\u4ef6\u9519\u8bef\u800c\u6302\u8d77\u65f6\u81ea\u52a8\u91cd\u542f\u7cfb\u7edf\u3002\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\uff0c\u907f\u514d\u7ec8\u7aef\u5361\u987f\u3001\u5173\u673a\u6162\u7b49\u95ee\u9898\u3002<\/p>\n","protected":false},"author":1,"featured_media":287517,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-287516","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/287516","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=287516"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/287516\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/287517"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=287516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=287516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=287516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}