{"id":94301,"date":"2026-08-14T08:49:01","date_gmt":"2026-08-14T00:49:01","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/94301.html"},"modified":"2026-08-14T08:49:01","modified_gmt":"2026-08-14T00:49:01","slug":"systemd-%e5%ad%a6%e4%b9%a0%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/94301.html","title":{"rendered":"Systemd \u5b66\u4e60\u603b\u7ed3"},"content":{"rendered":"<p>\u513f\u65f6\u7ec3\u529f\u6613&#xff0c;\u8001\u6765\u5b66\u827a\u96be\u3002<\/p>\n<h3>\u5bfc\u822a<\/h3>\n<ul>\n<li>0 \u524d\u8a00<\/li>\n<li>1 \u5de5\u5177\u4ecb\u7ecd<\/li>\n<li>2 \u914d\u7f6e\u7ed3\u6784<\/li>\n<li>3 Unit \u5b9e\u4f8b\n<ul>\n<li>3.0 \u901a\u7528\u5757\n<ul>\n<li>3.0.1 Unit \u5757\u53c2\u6570<\/li>\n<li>3.0.2 Install \u5757\u53c2\u6570<\/li>\n<\/ul>\n<\/li>\n<li>3.1 Service<\/li>\n<li>3.2 Target<\/li>\n<li>3.3 Timer<\/li>\n<li>3.4 Path<\/li>\n<li>3.5 Slice<\/li>\n<li>3.5 Mount<\/li>\n<li>3.6 Automount<\/li>\n<\/ul>\n<\/li>\n<li>4 \u547d\u4ee4\u7ba1\u7406\n<ul>\n<li>4.1 systemctl \u547d\u4ee4\u7528\u6cd5<\/li>\n<li>4.2 journalctl \u547d\u4ee4\u7528\u6cd5<\/li>\n<\/ul>\n<\/li>\n<li>5 \u6742\u4e03\u6742\u516b<\/li>\n<\/ul>\n<hr \/>\n<h3>\n<p>   0\u3001\u524d\u8a00<br \/>\n <\/h3>\n<p>\u5f53\u6211\u4eec\u6253\u5f00 Linux \u4e3b\u673a\u4ee5\u547d\u4ee4\u884c\u6a21\u5f0f\u6216\u56fe\u5f62\u5316\u6a21\u5f0f\u8fdb\u5165\u7cfb\u7edf\u4e4b\u540e&#xff0c;\u7cfb\u7edf\u5c31\u5df2\u7ecf\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5f88\u591a\u7684\u670d\u52a1&#xff0c;\u5982&#xff1a;\u6253\u5370\u670d\u52a1\u3001\u8ba1\u5212\u4efb\u52a1\u670d\u52a1\u3001\u90ae\u4ef6\u670d\u52a1\u7b49\u7b49&#xff0c;\u90a3\u4e48\u8fd9\u4e9b\u670d\u52a1\u662f\u5982\u4f55\u88ab\u542f\u52a8\u8d77\u6765\u7684\u5462&#xff1f;\u5728\u6b64\u4e4b\u524d\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0b Linux \u4e3b\u673a\u7684\u542f\u52a8\u8fc7\u7a0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260814004859-6a7e65fbcd3f8.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<li>\u70b9\u51fb\u4e3b\u673a\u5f00\u673a\u6309\u94ae&#xff0c;CPU \u5f00\u59cb\u52a0\u8f7d\u56fa\u4ef6\u7a0b\u5e8f&#xff08;\u5373 BIOS \u4e0a\u7535\u81ea\u68c0&#xff09;&#xff0c;\u5f85\u52a0\u8f7d\u5b8c\u6bd5\u4e4b\u540e BIOS \u4fbf\u83b7\u5f97\u4e86 CPU \u7684\u63a7\u5236\u6743&#xff0c;\u7136\u540e BIOS \u4f1a\u53bb\u52a0\u8f7d\u5f00\u673a\u542f\u52a8\u987a\u5e8f\u4e2d\u6307\u5b9a\u7684\u7cfb\u7edf\u5165\u53e3\u70b9&#xff08;\u5b89\u88c5\u7cfb\u7edf\u7684\u5149\u9a71\u3001\u786c\u76d8\u7684\u5165\u53e3\u70b9&#xff09;\u3002<\/li>\n<li>\u5f85 BIOS \u52a0\u8f7d\u4e86\u5165\u53e3\u70b9\u5904\u7684\u5f15\u5bfc\u88c5\u8f7d\u7a0b\u5e8f (GRUB2)\u4e4b\u540e&#xff0c;CPU \u63a7\u5236\u6743\u6b64\u65f6\u4fbf\u5230\u4e86 GRUB2 \u7684\u624b\u91cc&#xff0c;GRUB2 \u63a5\u7740\u5f00\u59cb\u52a0\u8f7d\u786c\u76d8\u4e2d\u5b89\u88c5\u7684 Linux \u5185\u6838\u3002<\/li>\n<li>\u5f85 Linux \u5185\u6838\u521d\u59cb\u5316\u5b8c\u6210\u4e4b\u540e&#xff0c;CPU \u7684\u63a7\u5236\u6743\u6b64\u65f6\u4fbf\u5230\u4e86 Linux \u5185\u6838\u624b\u4e2d&#xff0c;\u5f80\u540e CPU \u7684\u63a7\u5236\u6743\u4fbf\u4e00\u76f4\u638c\u63e1\u5728 Linux \u5185\u6838\u624b\u4e2d\u3002<\/li>\n<li>\u4f46 Linux \u5185\u6838\u5bf9\u4e8e\u7528\u6237\u6765\u8bf4\u5e76\u4e0d\u53ef\u76f4\u63a5\u88ab\u4f7f\u7528\u3001\u800c\u4e14\u4e5f\u5e76\u672a\u63d0\u4f9b\u4ec0\u4e48\u529f\u80fd&#xff0c;\u4e8e\u662f\u5b83\u53c8\u96c7\u4f63\u4e86\u4e00\u4e2a\u7ba1\u5bb6&#xff08;init\u3001systemd&#xff09;\u5e76\u6388\u4e88\u4e86\u4e00\u4e9b\u6743\u5229&#xff0c;\u6765\u4ee3\u66ff\u5b83\u53bb\u505a\u4e00\u4e9b\u7cfb\u7edf\u7ba1\u7406\u7684\u4e8b\u60c5\u3002\u800c\u8fd9\u4e2a\u7ba1\u5bb6\u4fbf\u662f Linux \u5185\u6838\u638c\u6743\u4e4b\u540e\u542f\u52a8\u7684\u7b2c\u4e00\u4e2a\u5916\u90e8\u7a0b\u5e8f&#xff0c;\u4e5f\u662f\u672a\u6765\u6240\u6709\u5176\u5b83\u8fdb\u7a0b\u4e4b\u7236\u3002<\/li>\n<p>\u65e9\u671f \u5404 Linux \u53d1\u884c\u5546\u4e3a\u81ea\u5bb6 Linux \u5185\u6838\u914d\u5907\u7684\u7ba1\u5bb6\u662f init \u8fd9\u4e2a\u7a0b\u5e8f&#xff0c;\u8be5\u7ba1\u5bb6\u7684\u7279\u70b9\u662f&#xff1a;&#xff08;1&#xff09;\u57fa\u4e8e\u811a\u672c\u5f0f\u7684\u65b9\u5f0f\u53bb\u7ba1\u7406\u670d\u52a1&#xff0c;\u670d\u52a1\u7684\u542f\u52a8\/\u505c\u6b62\/\u72b6\u6001\u67e5\u770b\u90fd\u662f\u901a\u8fc7 \/etc\/init.d\/ \u4e0b\u7684 bash \u811a\u672c\u6765\u5b9e\u73b0\u7684\u3002&#xff08;2&#xff09;\u5f00\u673a\u542f\u52a8\u5404\u79cd\u670d\u52a1\u7684\u65f6\u5019&#xff0c;\u53ea\u80fd\u4e00\u4e2a\u4e00\u4e2a\u4f9d\u5e8f\u8fdb\u884c&#xff0c;\u4e0d\u80fd\u591f\u5e76\u884c\u542f\u52a8\u3002&#xff08;3&#xff09;\u670d\u52a1\u4e4b\u95f4\u7684\u4f9d\u8d56\u95ee\u9898\u9700\u8981\u7ba1\u7406\u5458\u624b\u52a8\u5904\u7406\u3002&#xff08;4&#xff09;\u7cfb\u7edf\u73af\u5883\u5207\u6362\u4f9d\u8d56\u4e8e \/etc\/rc*.d\/ \u4e2d\u7684\u811a\u672c\u3002<\/p>\n<p>\u5982\u4eca \u5404 Linux \u53d1\u884c\u5546\u4e3a\u81ea\u5bb6 Linux \u5185\u6838\u914d\u5907\u7684\u7ba1\u5bb6\u57fa\u672c\u90fd\u662f systemd \u8fd9\u4e2a\u7a0b\u5e8f&#xff0c;\u8be5\u7ba1\u5bb6\u7684\u7279\u70b9\u662f&#xff1a;&#xff08;1&#xff09;\u57fa\u4e8e\u914d\u7f6e\u6587\u4ef6&#xff08;\u670d\u52a1\u5355\u4f4d Unit &#xff09;\u7684\u65b9\u5f0f\u53bb\u7ba1\u7406\u670d\u52a1&#xff0c;\u670d\u52a1\u7684\u7ba1\u7406\u66f4\u7075\u6d3b\u3001\u66f4\u7b80\u5355\u3002&#xff08;2&#xff09;\u652f\u6301\u5e76\u884c\u542f\u52a8\u5f00\u673a\u81ea\u542f\u5e94\u7528\u3002&#xff08;3&#xff09;\u670d\u52a1\u4e4b\u95f4\u7684\u4f9d\u8d56\u4f1a\u81ea\u52a8\u68c0\u67e5&#xff0c;\u5e76\u81ea\u52a8\u5524\u9192\u3002&#xff08;4&#xff09;\u517c\u5bb9\u65e7\u6709\u7684 init \u670d\u52a1\u811a\u672c\u542f\u52a8\u65b9\u5f0f\u3002<\/p>\n<p>\u7531\u4e8e\u5982\u4eca\u7684 Linux \u4f7f\u7528\u7684\u670d\u52a1\u7ba1\u7406\u65b9\u5f0f\u591a\u662f Systemd&#xff0c;\u56e0\u6b64\u5b66\u4f1a\u5b83\u8fd8\u662f\u5f88\u6709\u5fc5\u8981\u7684\u3002<\/p>\n<p>\u6ce8&#xff1a;Linxu \u5185\u6838\u542f\u52a8\u7684\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\u662f systemd&#xff0c;\u800c systemd \u542f\u52a8\u7684\u7b2c\u4e00\u4e2a\u670d\u52a1\u5355\u5143\u662f default.target&#xff0c;\u5b83\u4e00\u822c\u88ab\u547d\u4ee4 systemctl set-default multi-user.target \u94fe\u63a5\u5230\u4e86 multi-user.target \u6216 graphical.target\u3002<\/p>\n<p>\u5f53 systemd \u542f\u52a8\u4efb\u4f55\u670d\u52a1\u5355\u5143 Unit \u6587\u4ef6\u7684\u65f6\u5019&#xff0c;systemd \u9996\u5148\u53bb\u542f\u52a8\u53c2\u6570 Requires \u548c\u76ee\u5f55 \/etc\/systemd\/system\/a.target.requires\/ \u5173\u8054\u7684\u670d\u52a1&#xff0c;\u7136\u540e\u518d\u5f00\u59cb\u542f\u52a8\u53c2\u6570 Wants \u548c\u76ee\u5f55 \/etc\/systemd\/system\/a.target.want\/ \u5173\u8054\u7684\u670d\u52a1\u3002<\/p>\n<p> systemd \u627e\u5bfb default.target \u5355\u5143\u6587\u4ef6\u65f6\u7684\u76ee\u5f55\u67e5\u627e\u987a\u5e8f&#xff1a;<\/p>\n<p>\/etc\/systemd\/system\/default.target<br \/>\n     \u2193<br \/>\n\/run\/systemd\/system\/default.target<br \/>\n     \u2193<br \/>\n\/usr\/local\/lib\/systemd\/system\/default.target<br \/>\n     \u2193<br \/>\n\/usr\/lib\/systemd\/system\/default.target<br \/>\n     \u2193<br \/>\n\/lib\/systemd\/system\/default.target<\/p>\n<h3>\n<p>   1\u3001\u5de5\u5177\u4ecb\u7ecd<br \/>\n <\/h3>\n<p>Systemd \u662f\u57fa\u4e8e\u670d\u52a1\u5355\u4f4d Unit \u6765\u7ba1\u7406\u5b88\u62a4\u8fdb\u7a0b\u548c\u7cfb\u7edf\u8d44\u6e90\u7684&#xff0c;\u5b83\u5c06\u8fd9\u4e9b\u670d\u52a1\u5355\u4f4d Unit \u5212\u5206\u6210\u4e86 service\u3001target\u3001timer\u3001path\u3001socket \u7b49 12 \u79cd\u4e0d\u540c\u7684\u7c7b\u578b&#xff0c;\u6bcf\u79cd\u7c7b\u578b\u5206\u522b\u5bf9\u5e94\u7740\u4e0d\u540c\u7684\u529f\u80fd\u548c\u5e94\u7528\u573a\u666f\u4ee5\u65b9\u4fbf\u7ba1\u7406\u5458\u4f7f\u7528\u3002\u6b64\u5916&#xff0c;Systemd \u8fd8\u7ef4\u62a4\u7740\u4e00\u4e2a\u540d\u4e3a journald \u7684\u65e5\u5fd7\u7cfb\u7edf\u6765\u8bb0\u5f55\u5b83\u6240\u7ba1\u7406\u7684\u670d\u52a1\u5728\u8fd0\u884c\u65f6\u4ea7\u751f\u7684\u5404\u79cd\u65e5\u5fd7\u4fe1\u606f\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260814004900-6a7e65fc06e53.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5982\u56fe\u6240\u89c1&#xff0c;Systemd \u5728 Linux \u7cfb\u7edf\u4e2d\u7684\u5730\u4f4d\u5f88\u91cd\u8981&#xff0c;\u56e0\u4e3a\u5b83\u5fc5\u987b\u786e\u4fdd\u7cfb\u7edf\u542f\u52a8\u5e76\u51c6\u5907\u5c31\u7eea&#xff0c;\u6240\u4ee5\u5b83\u627f\u62c5\u7684\u4e8b\u60c5\u4e5f\u6bd4\u8f83\u591a&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<ul>\n<li>\u5b83\u4f1a\u542f\u52a8\u6240\u6709\u4f60\u9700\u8981\u7684\u540e\u53f0\u670d\u52a1&#xff0c;\u4f8b\u5982\u7f51\u7edc\u3001\u6253\u5370\u3001\u5bb9\u5668\u3001\u6570\u636e\u5e93\u7b49\u3002\u3010\u540e\u53f0\u670d\u52a1\u7ba1\u7406\u3011<\/li>\n<li>\u5b83\u4f1a\u81ea\u52a8\u6302\u8f7d\u6240\u6709\u4e0d\u540c\u7684\u6587\u4ef6\u7cfb\u7edf\u548c\u78c1\u76d8&#xff0c;\u4ee5\u4fbf\u53ef\u4ee5\u968f\u65f6\u8bbf\u95ee\u3002\u3010\u5f00\u673a\u6302\u8f7d\u3011<\/li>\n<li>\u4e00\u65e6\u8fdb\u5165\u56fe\u5f62\u63d0\u793a\u7b26&#xff0c;\u5b83\u5c31\u4f1a\u5904\u7406\u7528\u6237\u767b\u5f55\u3001\u606f\u5c4f\u548c\u5173\u673a\u3002\u3010\u7528\u6237\u767b\u5f55\u4e0e\u4f1a\u8bdd\u7ba1\u7406\u3011<\/li>\n<li>\u5b83\u4f1a\u81ea\u52a8\u6e05\u7406\u4e34\u65f6\u5783\u573e\u6587\u4ef6&#xff0c;\u6216\u8005\u6bcf\u5929\u81ea\u52a8\u5907\u4efd\u6570\u636e\u3002\u3010\u5b9a\u65f6\u4efb\u52a1\u3011<\/li>\n<li>\u5b83\u4f1a\u5b9e\u65f6\u6536\u96c6\u5e76\u5f52\u6863\u5185\u6838\u3001\u7cfb\u7edf\u670d\u52a1\u4ee5\u53ca\u5404\u79cd\u8f6f\u4ef6\u6253\u5370\u51fa\u6765\u7684\u65e5\u5fd7\u3002\u3010\u65e5\u5fd7\u8bb0\u5f55\u3011<\/li>\n<\/ul>\n<h3>\n<p>   2\u3001\u914d\u7f6e\u7ed3\u6784<br \/>\n <\/h3>\n<p>Systemd \u7ba1\u7406\u7684\u670d\u52a1\u6240\u5bf9\u5e94\u7684\u670d\u52a1\u5355\u5143 Unit \u6587\u4ef6\u7684\u5b58\u653e\u8def\u5f84\u5982\u4e0b&#xff08;\u6ce8&#xff1a;\u8fd9\u4e9b\u8def\u5f84\u5b58\u5728 \u4f18\u5148\u7ea7\u8986\u76d6\u5173\u7cfb&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u76ee\u5f55\u8def\u5f84\u4f5c\u7528\u4e0e\u7279\u70b9\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>\/etc\/systemd\/system\/<\/td>\n<td>\u6700\u9ad8\u4f18\u5148\u7ea7\u3002\u5b58\u653e\u7ba1\u7406\u5458\u624b\u52a8\u521b\u5efa\u6216\u4fee\u6539\u7684\u5355\u5143\u6587\u4ef6&#xff0c;\u4ee5\u53ca\u5f00\u673a\u81ea\u542f\u670d\u52a1\u7684\u8f6f\u94fe\u63a5\u3002<\/td>\n<td>\u7528\u6237\u81ea\u5b9a\u4e49\u670d\u52a1\u3001\u4fee\u6539\u7cfb\u7edf\u9ed8\u8ba4\u914d\u7f6e\u3002<\/td>\n<\/tr>\n<tr>\n<td>\/run\/systemd\/system\/<\/td>\n<td>\u4e2d\u7b49\u4f18\u5148\u7ea7\u3002\u5b58\u653e\u7cfb\u7edf\u8fd0\u884c\u671f\u95f4\u52a8\u6001\u751f\u6210\u7684\u4e34\u65f6\u5355\u5143\u6587\u4ef6&#xff08;\u91cd\u542f\u540e\u4e22\u5f03&#xff09;\u3002<\/td>\n<td>\u7a0b\u5e8f\u8fd0\u884c\u65f6\u4e34\u65f6\u4ea7\u751f\u7684\u670d\u52a1\u3001\u6302\u8f7d\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>\/lib\/systemd\/system\/ (\u6216 \/usr\/lib\/systemd\/system\/)<\/td>\n<td>\u6700\u4f4e\u4f18\u5148\u7ea7\u3002\u5b58\u653e\u901a\u8fc7\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668&#xff08;\u5982 apt\u3001dnf&#xff09;\u5b89\u88c5\u7684\u670d\u52a1\u9ed8\u8ba4\u914d\u7f6e\u3002<\/td>\n<td>\u7cfb\u7edf\u4e0e\u8f6f\u4ef6\u81ea\u5e26\u7684\u539f\u59cb\u914d\u7f6e&#xff0c;\u8bf7\u52ff\u76f4\u63a5\u4fee\u6539\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6b64\u5916&#xff0c;\u5728\u4fee\u6539\u5355\u5143\u914d\u7f6e\u6587\u4ef6\u65f6&#xff0c;\u5b98\u65b9\u5efa\u8bae\u4e0d\u8981\u76f4\u63a5\u5728\u6e90\u6587\u4ef6&#xff08;\u5373 \/usr\/lib\/systemd\/system\/* \u4e2d\u7684\u5355\u5143\u6587\u4ef6&#xff09;\u4e2d\u8fdb\u884c\u4fee\u6539&#xff0c;\u800c\u662f\u4f18\u5148\u5728 \/etc\/systemd\/system\/* \u4e2d\u8fdb\u884c\u4fee\u6539\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u4f60\u60f3\u989d\u5916\u4fee\u6539 vsftpd.service \u7684\u8bdd&#xff0c;\u5219\u5e94\u8be5\u6309\u5982\u4e0b\u65b9\u5f0f\u5904\u7406&#xff1a;<\/p>\n<table>\n<tr>\u76ee\u5f55\u8def\u5f84\u4f5c\u7528\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\/usr\/lib\/systemd\/system\/vsftpd.service<\/td>\n<td>\u5b98\u65b9\u91ca\u51fa\u7684\u9884\u8bbe\u8bbe\u5b9a\u6863&#xff0c;\u4e0d\u8981\u52a8\u3002<\/td>\n<\/tr>\n<tr>\n<td>\/etc\/systemd\/system\/vsftpd.service.d\/custom.conf<\/td>\n<td>\u5728 \/etc\/systemd\/system \u5e95\u4e0b\u5efa\u7acb\u4e0e\u8bbe\u5b9a\u6863\u76f8\u540c\u6863\u540d\u7684\u76ee\u5f55&#xff0c;\u4f46\u662f\u8981\u52a0\u4e0a .d \u7684\u526f\u6863\u540d\u3002\u7136\u540e\u5728\u8be5\u76ee\u5f55\u4e0b\u5efa\u7acb\u8bbe\u5b9a\u6863\u5373\u53ef\u3002\u53e6\u5916&#xff0c;\u8bbe\u5b9a\u6863\u6700\u597d\u9644\u6863\u540d\u53d6\u540d\u4e3a .conf \u8f83\u4f73&#xff01; \u5728\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u7684\u6863\u6848\u4f1a\u201c\u7d2f\u52a0\u5176\u4ed6\u8bbe\u5b9a\u201d\u8fdb\u5165 \/usr\/lib\/systemd\/system\/vsftpd.service \u5185\u3002<\/td>\n<\/tr>\n<tr>\n<td>\/etc\/systemd\/system\/vsftpd.service.wants\/*<\/td>\n<td>\u6b64\u76ee\u5f55\u5185\u7684\u6863\u6848\u4e3a\u8fde\u7ed3\u6863&#xff0c;\u8bbe\u5b9a\u76f8\u4f9d\u670d\u52a1\u7684\u8fde\u7ed3\u3002\u610f\u601d\u662f\u542f\u52a8\u4e86 vsftpd.service \u4e4b\u540e&#xff0c;\u6700\u597d\u518d\u52a0\u4e0a\u8fd9\u76ee\u5f55\u5e95\u4e0b\u5efa\u8bae\u7684\u670d\u52a1\u3002<\/td>\n<\/tr>\n<tr>\n<td>\/etc\/systemd\/system\/vsftpd.service.requires\/*<\/td>\n<td>\u6b64\u76ee\u5f55\u5185\u7684\u6863\u6848\u4e3a\u8fde\u7ed3\u6863&#xff0c;\u8bbe\u5b9a\u76f8\u4f9d\u670d\u52a1\u7684\u8fde\u7ed3\u3002\u610f\u601d\u662f\u5728\u542f\u52a8 vsftpd.service \u4e4b\u524d&#xff0c;\u9700\u8981\u4e8b\u5148\u542f\u52a8\u54ea\u4e9b\u670d\u52a1\u7684\u610f\u601d\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6700\u7ec8&#xff0c;\u5f53\u6267\u884c systemctl start vsftpd.service \u547d\u4ee4\u65f6&#xff0c;systemctl \u4f1a\u5c06\u4ee5\u4e0a 4 \u4e2a\u76ee\u5f55\u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u4fe1\u606f\u90fd\u805a\u5408\u8d77\u6765\u5f62\u6210\u4e00\u4efd\u8fd0\u884c\u65f6 service \u670d\u52a1\u5355\u5143\u53bb\u6267\u884c\u3002\u4e0d\u8fc7\u8fd9\u79cd\u7528\u6cd5\u4e2a\u4eba\u89c9\u5f97\u8fd8\u662f\u592a\u9ebb\u70e6&#xff0c;\u8fd8\u4e0d\u5982\u76f4\u63a5\u62f7\u8d1d\u4e00\u4efd\u6e90\u6587\u4ef6\u5728 \/etc\/systemd\/system\/vsftpd.service \u7136\u540e\u76f4\u63a5\u4fee\u6539\u5b83\u6765\u7684\u5bb9\u6613\u3002<\/p>\n<h3>\n<p>   3\u3001Unit \u5b9e\u4f8b<br \/>\n <\/h3>\n<p>Systemd \u6240\u5212\u5206\u7684 12 \u79cd Unit \u7c7b\u578b\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>Unit \u7c7b\u578b\u6587\u4ef6\u540e\u7f00\u4f5c\u7528\u5e38\u89c1\u7528\u9014<\/tr>\n<tbody>\n<tr>\n<td>Service Unit<\/td>\n<td>.service<\/td>\n<td>\u7ba1\u7406\u7cfb\u7edf\u670d\u52a1\/\u8fdb\u7a0b<\/td>\n<td>\u542f\u52a8 nginx\u3001docker\u3001ssh<\/td>\n<\/tr>\n<tr>\n<td>Target Unit<\/td>\n<td>.target<\/td>\n<td>\u7ba1\u7406\u4e00\u7ec4 Unit \u7684\u96c6\u5408<\/td>\n<td>\u7c7b\u4f3c\u8fd0\u884c\u7ea7\u522b<\/td>\n<\/tr>\n<tr>\n<td>Timer Unit<\/td>\n<td>.timer<\/td>\n<td>\u5b9a\u65f6\u4efb\u52a1<\/td>\n<td>\u66ff\u4ee3 cron<\/td>\n<\/tr>\n<tr>\n<td>Path Unit<\/td>\n<td>.path<\/td>\n<td>\u76d1\u63a7\u6587\u4ef6\u8def\u5f84\u53d8\u5316<\/td>\n<td>\u6587\u4ef6\u53d8\u5316\u89e6\u53d1\u4efb\u52a1<\/td>\n<\/tr>\n<tr>\n<td>Slice Unit<\/td>\n<td>.slice<\/td>\n<td>\u7ba1\u7406\u8d44\u6e90\u5206\u7ec4<\/td>\n<td>CPU\/\u5185\u5b58\u9650\u5236<\/td>\n<\/tr>\n<tr>\n<td>Mount Unit<\/td>\n<td>.mount<\/td>\n<td>\u7ba1\u7406\u6587\u4ef6\u7cfb\u7edf\u6302\u8f7d<\/td>\n<td>\u81ea\u52a8\u6302\u8f7d\u78c1\u76d8<\/td>\n<\/tr>\n<tr>\n<td>Automount Unit<\/td>\n<td>.automount<\/td>\n<td>\u6309\u9700\u6302\u8f7d\u6587\u4ef6\u7cfb\u7edf<\/td>\n<td>\u5ef6\u8fdf\u6302\u8f7d<\/td>\n<\/tr>\n<tr>\n<td>Swap Unit<\/td>\n<td>.swap<\/td>\n<td>\u7ba1\u7406 swap \u5206\u533a\/\u6587\u4ef6<\/td>\n<td>\u5f00\u542f\u4ea4\u6362\u7a7a\u95f4<\/td>\n<\/tr>\n<tr>\n<td>Scope Unit<\/td>\n<td>.scope<\/td>\n<td>\u7ba1\u7406\u5916\u90e8\u8fdb\u7a0b<\/td>\n<td>\u7528\u6237\u4f1a\u8bdd\u3001\u5bb9\u5668<\/td>\n<\/tr>\n<tr>\n<td>Socket Unit<\/td>\n<td>.socket<\/td>\n<td>\u7ba1\u7406 socket \u901a\u4fe1<\/td>\n<td>socket \u6fc0\u6d3b\u670d\u52a1<\/td>\n<\/tr>\n<tr>\n<td>Device Unit<\/td>\n<td>.device<\/td>\n<td>\u7ba1\u7406\u786c\u4ef6\u8bbe\u5907<\/td>\n<td>\u78c1\u76d8\u3001USB \u8bbe\u5907<\/td>\n<\/tr>\n<tr>\n<td>Snapshot Unit<\/td>\n<td>.snapshot<\/td>\n<td>\u4fdd\u5b58\u5f53\u524d\u72b6\u6001<\/td>\n<td>\u7cfb\u7edf\u72b6\u6001\u5feb\u7167<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\n<p>   3.0\u3001\u901a\u7528\u5757<br \/>\n <\/h4>\n<p>\u6bcf\u79cd Unit \u914d\u7f6e\u6587\u4ef6\u7684\u8bed\u6cd5\u683c\u5f0f\u57fa\u672c\u90fd\u662f\u7531 3 \u5927\u5757\u7ec4\u6210&#xff1a;\u901a\u7528\u7684\u3010Unit \u5757 &#043; Install \u5757\u3011&#xff0c;\u4ee5\u53ca\u72ec\u5c5e\u4e8e\u6bcf\u79cd Unit \u7c7b\u578b\u4e13\u5c5e\u7684\u3010Service \u5757\u3001Timer \u5757\u3001Path \u5757\u7b49\u3011\u3002\u4e0b\u9762\u6211\u5c06\u5c55\u793a \u901a\u7528\u5757\u3010Unit \u5757 &#043; Install \u5757\u3011\u7684\u5e38\u7528\u53c2\u6570&#xff0c;\u800c\u5173\u4e8e\u6bcf\u79cd Unit \u4e13\u5c5e\u5757 \u7684\u5e38\u7528\u53c2\u6570\u5219\u5728\u5404\u81ea\u7684\u5c0f\u8282\u8fdb\u884c\u5c55\u793a\u3002<\/p>\n<h5>\n<p>   3.0.1\u3001Unit \u5757\u53c2\u6570<br \/>\n <\/h5>\n<p>\u3010Unit \u5757\u3011\u5e38\u7528\u53c2\u6570\u5217\u8868&#xff1a;<\/p>\n<table>\n<tr>\u8bbe\u5b9a\u53c2\u6570\u53c2\u6570\u610f\u4e49\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>Description<\/td>\n<td>\u5bf9\u5f53\u524d Unit \u7684\u529f\u80fd\u8fdb\u884c\u7b80\u77ed\u63cf\u8ff0&#xff0c;\u6267\u884c systemctl status \u65f6\u901a\u5e38\u53ef\u4ee5\u770b\u5230\u3002<\/td>\n<\/tr>\n<tr>\n<td>Documentation<\/td>\n<td>\u6307\u5b9a\u8be5 Unit \u7684\u76f8\u5173\u6587\u6863\u5730\u5740&#xff0c;\u53ef\u4ee5\u662f man:\u3001info: \u6216 URL\u3002<\/td>\n<\/tr>\n<tr>\n<td>Requires<\/td>\n<td>\u5f3a\u4f9d\u8d56\u5173\u7cfb\u3002\u5f53\u524d Unit \u542f\u52a8\u65f6&#xff0c;\u4f1a\u5c1d\u8bd5\u542f\u52a8\u8fd9\u91cc\u6307\u5b9a\u7684 Unit&#xff1b;\u5982\u679c\u4f9d\u8d56 Unit \u88ab\u505c\u6b62\u6216\u542f\u52a8\u5931\u8d25&#xff0c;\u5f53\u524d Unit \u901a\u5e38\u4e5f\u4f1a\u53d7\u5230\u5f71\u54cd\u3002<\/td>\n<\/tr>\n<tr>\n<td>Wants<\/td>\n<td>\u5f31\u4f9d\u8d56\u5173\u7cfb\u3002\u5f53\u524d Unit \u542f\u52a8\u65f6&#xff0c;\u4f1a\u5c1d\u8bd5\u542f\u52a8\u8fd9\u91cc\u6307\u5b9a\u7684 Unit&#xff1b;\u4f46\u4f9d\u8d56 Unit \u542f\u52a8\u5931\u8d25&#xff0c;\u4e00\u822c\u4e0d\u4f1a\u5bfc\u81f4\u5f53\u524d Unit \u5931\u8d25\u3002<\/td>\n<\/tr>\n<tr>\n<td>Requisite<\/td>\n<td>\u8981\u6c42\u6307\u5b9a Unit \u5df2\u7ecf\u5904\u4e8e active \u72b6\u6001&#xff0c;\u5426\u5219\u5f53\u524d Unit \u4e0d\u4f1a\u542f\u52a8&#xff1b;\u5b83\u672c\u8eab\u4e0d\u4f1a\u4e3b\u52a8\u542f\u52a8\u4f9d\u8d56 Unit\u3002<\/td>\n<\/tr>\n<tr>\n<td>BindsTo<\/td>\n<td>\u6bd4 Requires \u66f4\u5f3a\u7684\u7ed1\u5b9a\u5173\u7cfb\u3002\u4f9d\u8d56 Unit \u6d88\u5931\u6216\u53d8\u4e3a inactive \u65f6&#xff0c;\u5f53\u524d Unit \u4e5f\u4f1a\u505c\u6b62\u3002<\/td>\n<\/tr>\n<tr>\n<td>PartOf<\/td>\n<td>\u5efa\u7acb\u505c\u6b62\/\u91cd\u542f\u4f20\u64ad\u5173\u7cfb\u3002\u5f53\u6307\u5b9a Unit \u88ab\u505c\u6b62\u6216\u91cd\u542f\u65f6&#xff0c;\u5f53\u524d Unit \u4e5f\u4f1a\u6267\u884c\u76f8\u5e94\u64cd\u4f5c\u3002<\/td>\n<\/tr>\n<tr>\n<td>Conflicts<\/td>\n<td>\u8868\u793a\u4e24\u4e2a Unit \u4e0d\u80fd\u540c\u65f6\u8fd0\u884c\u3002\u542f\u52a8\u4e00\u4e2a Unit \u65f6&#xff0c;\u4f1a\u505c\u6b62\u4e0e\u5b83\u5b58\u5728 Conflicts \u5173\u7cfb\u7684 Unit\u3002<\/td>\n<\/tr>\n<tr>\n<td>Before<\/td>\n<td>\u6307\u5b9a\u5f53\u524d Unit \u5fc5\u987b\u5728\u67d0\u4e9b Unit \u4e4b\u524d\u542f\u52a8\u3002\u53ea\u8d1f\u8d23\u542f\u52a8\u987a\u5e8f&#xff0c;\u4e0d\u5efa\u7acb\u4f9d\u8d56\u5173\u7cfb\u3002<\/td>\n<\/tr>\n<tr>\n<td>After<\/td>\n<td>\u6307\u5b9a\u5f53\u524d Unit \u5fc5\u987b\u5728\u67d0\u4e9b Unit \u4e4b\u540e\u542f\u52a8\u3002\u53ea\u8d1f\u8d23\u542f\u52a8\u987a\u5e8f&#xff0c;\u4e0d\u5efa\u7acb\u4f9d\u8d56\u5173\u7cfb\u3002<\/td>\n<\/tr>\n<tr>\n<td>Before \/ After<\/td>\n<td>\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\u3002\u4f8b\u5982 After&#061;network.target \u8868\u793a\u5f53\u524d Unit \u7684\u542f\u52a8\u987a\u5e8f\u6392\u5728 network.target \u540e\u9762\u3002<\/td>\n<\/tr>\n<tr>\n<td>Condition&#8230;<\/td>\n<td>\u542f\u52a8\u524d\u8fdb\u884c\u6761\u4ef6\u68c0\u67e5\u3002\u6761\u4ef6\u4e0d\u6ee1\u8db3\u65f6&#xff0c;Unit \u4f1a\u88ab\u8df3\u8fc7&#xff0c;\u800c\u4e0d\u662f\u8ba4\u4e3a\u542f\u52a8\u5931\u8d25\u3002<\/td>\n<\/tr>\n<tr>\n<td>Assert&#8230;<\/td>\n<td>\u542f\u52a8\u524d\u8fdb\u884c\u65ad\u8a00\u68c0\u67e5\u3002\u6761\u4ef6\u4e0d\u6ee1\u8db3\u65f6&#xff0c;Unit \u542f\u52a8\u4f1a\u88ab\u8ba4\u4e3a\u5931\u8d25\u3002<\/td>\n<\/tr>\n<tr>\n<td>DefaultDependencies<\/td>\n<td>\u662f\u5426\u81ea\u52a8\u6dfb\u52a0 systemd \u9ed8\u8ba4\u4f9d\u8d56\u5173\u7cfb&#xff0c;\u9ed8\u8ba4\u901a\u5e38\u4e3a yes\u3002<\/td>\n<\/tr>\n<tr>\n<td>OnFailure<\/td>\n<td>\u5f53\u524d Unit \u542f\u52a8\u5931\u8d25\u65f6&#xff0c;\u81ea\u52a8\u6fc0\u6d3b\u6307\u5b9a\u7684 Unit\u3002<\/td>\n<\/tr>\n<tr>\n<td>OnSuccess<\/td>\n<td>\u5f53\u524d Unit \u6210\u529f\u505c\u6b62\/\u5b8c\u6210\u540e&#xff0c;\u81ea\u52a8\u6fc0\u6d3b\u6307\u5b9a\u7684 Unit\u3002<\/td>\n<\/tr>\n<tr>\n<td>JobTimeoutSec<\/td>\n<td>\u8bbe\u7f6e\u7b49\u5f85\u8be5 Unit Job \u5b8c\u6210\u7684\u8d85\u65f6\u65f6\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>StartLimitIntervalSec<\/td>\n<td>\u5728\u6307\u5b9a\u65f6\u95f4\u7a97\u53e3\u5185\u9650\u5236 Unit \u7684\u542f\u52a8\u6b21\u6570\u3002<\/td>\n<\/tr>\n<tr>\n<td>StartLimitBurst<\/td>\n<td>\u6307\u5b9a\u65f6\u95f4\u7a97\u53e3\u5185\u5141\u8bb8\u7684\u6700\u5927\u542f\u52a8\u6b21\u6570&#xff0c;\u901a\u5e38\u4e0e StartLimitIntervalSec \u914d\u5408\u4f7f\u7528\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>\n<p>   3.0.2\u3001Install \u5757\u53c2\u6570<br \/>\n <\/h5>\n<p>\u3010Install \u5757\u3011\u5e38\u7528\u53c2\u6570\u5217\u8868&#xff1a;<\/p>\n<table>\n<tr>\u8bbe\u5b9a\u53c2\u6570\u53c2\u6570\u610f\u4e49\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>WantedBy<\/td>\n<td>\u6307\u5b9a\u5f53\u524d Unit \u5e94\u8be5\u88ab\u54ea\u4e2a Target \u4ee5 Wants \u5173\u7cfb\u62c9\u8d77\u3002\u6267\u884c systemctl enable \u65f6&#xff0c;\u4f1a\u5728\u5bf9\u5e94 Target \u7684 .wants\/ \u76ee\u5f55\u4e2d\u521b\u5efa\u7b26\u53f7\u94fe\u63a5\u3002<\/td>\n<\/tr>\n<tr>\n<td>RequiredBy<\/td>\n<td>\u4e0e WantedBy \u7c7b\u4f3c&#xff0c;\u4f46\u5efa\u7acb\u7684\u662f Requires \u5173\u7cfb&#xff0c;\u542f\u7528\u5f53\u524d Unit \u65f6\u4f1a\u5728\u5bf9\u5e94 Target \u7684 .requires\/ \u76ee\u5f55\u5efa\u7acb\u94fe\u63a5\u3002<\/td>\n<\/tr>\n<tr>\n<td>Also<\/td>\n<td>\u5f53\u6267\u884c systemctl enable \u6216 disable \u5f53\u524d Unit \u65f6&#xff0c;\u540c\u65f6\u5bf9\u6307\u5b9a\u7684\u5176\u4ed6 Unit \u6267\u884c\u76f8\u5e94\u64cd\u4f5c\u3002<\/td>\n<\/tr>\n<tr>\n<td>Alias<\/td>\n<td>\u4e3a\u5f53\u524d Unit \u521b\u5efa\u522b\u540d\u3002\u542f\u7528 Unit \u65f6&#xff0c;\u4f1a\u5efa\u7acb\u5bf9\u5e94\u7684\u7b26\u53f7\u94fe\u63a5&#xff0c;\u4f7f\u5f97\u53ef\u4ee5\u901a\u8fc7\u522b\u540d\u64cd\u4f5c\u540c\u4e00\u4e2a Unit\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\n<p>   3.1\u3001Service<br \/>\n <\/h4>\n<p>\u5355\u5143\u4ecb\u7ecd&#xff1a;\u6700\u57fa\u672c\u7684\u5355\u5143&#xff0c;\u4e3b\u8981\u7528\u6765\u542f\u52a8\u670d\u52a1\u8fdb\u7a0b&#xff0c;\u540c\u65f6\u4e5f\u662f target\u3001timer\u3001path\u3001socket \u8fd9\u4e9b\u5355\u5143\u6240\u9700\u7684\u57fa\u672c\u5355\u5143\u3002<\/p>\n<p>\u671f\u671b\u76ee\u6807&#xff1a;\u4e00\u6761\u547d\u4ee4\u542f\u52a8\/\u505c\u6b62 nginx \u670d\u52a1\u8fdb\u7a0b\u3002<\/p>\n<p># cat nginx.service<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Nginx Web Server<br \/>\nAfter&#061;network.target<\/p>\n<p>[Service]<br \/>\nExecStart&#061;\/usr\/sbin\/nginx<br \/>\nExecStop&#061;\/usr\/sbin\/nginx -s stop<br \/>\nRestart&#061;always<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p>\u3010Service \u5757\u3011\u5e38\u7528\u53c2\u6570\u5217\u8868&#xff1a;<\/p>\n<table>\n<tr>\u8bbe\u5b9a\u53c2\u6570\u53c2\u6570\u610f\u4e49\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>Type<\/td>\n<td>\u6307\u5b9a\u670d\u52a1\u7684\u542f\u52a8\u7c7b\u578b&#xff0c;\u5e38\u89c1\u6709 simple\u3001exec\u3001forking\u3001oneshot\u3001dbus\u3001notify\u3001idle\u3002<\/td>\n<\/tr>\n<tr>\n<td>ExecStart<\/td>\n<td>\u6307\u5b9a\u542f\u52a8\u670d\u52a1\u65f6\u6267\u884c\u7684\u547d\u4ee4&#xff0c;\u662f\u6700\u6838\u5fc3\u7684 Service \u53c2\u6570\u4e4b\u4e00\u3002<\/td>\n<\/tr>\n<tr>\n<td>ExecStartPre<\/td>\n<td>\u5728 ExecStart \u4e4b\u524d\u6267\u884c\u7684\u547d\u4ee4&#xff0c;\u5e38\u7528\u4e8e\u542f\u52a8\u524d\u68c0\u67e5\u6216\u51c6\u5907\u5de5\u4f5c\u3002<\/td>\n<\/tr>\n<tr>\n<td>ExecStartPost<\/td>\n<td>ExecStart \u6210\u529f\u540e\u6267\u884c\u7684\u547d\u4ee4\u3002<\/td>\n<\/tr>\n<tr>\n<td>ExecReload<\/td>\n<td>\u6267\u884c systemctl reload xxx \u65f6\u8fd0\u884c\u7684\u547d\u4ee4&#xff0c;\u7528\u4e8e\u8ba9\u7a0b\u5e8f\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u3002<\/td>\n<\/tr>\n<tr>\n<td>ExecStop<\/td>\n<td>\u6267\u884c systemctl stop xxx \u65f6\u8fd0\u884c\u7684\u547d\u4ee4\u3002<\/td>\n<\/tr>\n<tr>\n<td>ExecStopPost<\/td>\n<td>\u670d\u52a1\u505c\u6b62\u540e\u6267\u884c\u7684\u547d\u4ee4&#xff0c;\u5e38\u7528\u4e8e\u6e05\u7406\u5de5\u4f5c\u3002<\/td>\n<\/tr>\n<tr>\n<td>Restart<\/td>\n<td>\u6307\u5b9a\u670d\u52a1\u9000\u51fa\u540e\u662f\u5426\u81ea\u52a8\u91cd\u65b0\u542f\u52a8&#xff0c;\u4f8b\u5982 no\u3001on-success\u3001on-failure\u3001always\u3002<\/td>\n<\/tr>\n<tr>\n<td>RestartSec<\/td>\n<td>\u670d\u52a1\u81ea\u52a8\u91cd\u542f\u524d\u7b49\u5f85\u591a\u957f\u65f6\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>RestartPreventExitStatus<\/td>\n<td>\u6307\u5b9a\u67d0\u4e9b\u9000\u51fa\u72b6\u6001\u7801\u65f6\u7981\u6b62\u81ea\u52a8\u91cd\u542f\u3002<\/td>\n<\/tr>\n<tr>\n<td>RestartForceExitStatus<\/td>\n<td>\u6307\u5b9a\u67d0\u4e9b\u9000\u51fa\u72b6\u6001\u7801\u65f6\u5f3a\u5236\u89e6\u53d1\u81ea\u52a8\u91cd\u542f\u3002<\/td>\n<\/tr>\n<tr>\n<td>User<\/td>\n<td>\u6307\u5b9a\u670d\u52a1\u8fdb\u7a0b\u4ee5\u54ea\u4e2a\u7528\u6237\u8eab\u4efd\u8fd0\u884c\u3002<\/td>\n<\/tr>\n<tr>\n<td>Group<\/td>\n<td>\u6307\u5b9a\u670d\u52a1\u8fdb\u7a0b\u4f7f\u7528\u7684\u7528\u6237\u7ec4\u3002<\/td>\n<\/tr>\n<tr>\n<td>WorkingDirectory<\/td>\n<td>\u6307\u5b9a\u670d\u52a1\u8fdb\u7a0b\u7684\u5de5\u4f5c\u76ee\u5f55\u3002<\/td>\n<\/tr>\n<tr>\n<td>Environment<\/td>\n<td>\u8bbe\u7f6e\u670d\u52a1\u8fd0\u884c\u65f6\u7684\u73af\u5883\u53d8\u91cf\u3002<\/td>\n<\/tr>\n<tr>\n<td>EnvironmentFile<\/td>\n<td>\u4ece\u6307\u5b9a\u6587\u4ef6\u8bfb\u53d6\u73af\u5883\u53d8\u91cf\u3002<\/td>\n<\/tr>\n<tr>\n<td>ExecSearchPath<\/td>\n<td>\u6307\u5b9a\u6267\u884c\u7a0b\u5e8f\u65f6\u641c\u7d22\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/td>\n<\/tr>\n<tr>\n<td>PIDFile<\/td>\n<td>\u6307\u5b9a\u670d\u52a1 PID \u6587\u4ef6\u7684\u4f4d\u7f6e&#xff0c;\u5e38\u7528\u4e8e Type&#061;forking \u7684\u670d\u52a1\u3002<\/td>\n<\/tr>\n<tr>\n<td>RemainAfterExit<\/td>\n<td>\u5bf9 Type&#061;oneshot \u7b49\u670d\u52a1\u6709\u7528&#xff0c;\u8868\u793a\u547d\u4ee4\u6267\u884c\u7ed3\u675f\u540e Unit \u662f\u5426\u7ee7\u7eed\u4fdd\u6301 active \u72b6\u6001\u3002<\/td>\n<\/tr>\n<tr>\n<td>TimeoutStartSec<\/td>\n<td>\u8bbe\u7f6e\u670d\u52a1\u542f\u52a8\u8d85\u65f6\u65f6\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>TimeoutStopSec<\/td>\n<td>\u8bbe\u7f6e\u670d\u52a1\u505c\u6b62\u8d85\u65f6\u65f6\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>TimeoutAbortSec<\/td>\n<td>\u670d\u52a1\u88ab\u4e2d\u6b62\u65f6\u5141\u8bb8\u7b49\u5f85\u7684\u65f6\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>KillMode<\/td>\n<td>\u6307\u5b9a\u505c\u6b62\u670d\u52a1\u65f6 systemd \u5982\u4f55\u5904\u7406\u670d\u52a1\u8fdb\u7a0b&#xff0c;\u4f8b\u5982 control-group\u3001process\u3001mixed\u3002<\/td>\n<\/tr>\n<tr>\n<td>KillSignal<\/td>\n<td>\u6307\u5b9a\u505c\u6b62\u670d\u52a1\u65f6\u9996\u5148\u53d1\u9001\u7684\u4fe1\u53f7&#xff0c;\u9ed8\u8ba4\u901a\u5e38\u4e3a SIGTERM\u3002<\/td>\n<\/tr>\n<tr>\n<td>SuccessExitStatus<\/td>\n<td>\u6307\u5b9a\u54ea\u4e9b\u9000\u51fa\u72b6\u6001\u88ab\u8ba4\u4e3a\u662f\u6b63\u5e38\u9000\u51fa\u3002<\/td>\n<\/tr>\n<tr>\n<td>StandardOutput<\/td>\n<td>\u6307\u5b9a\u6807\u51c6\u8f93\u51fa\u7684\u53bb\u5411&#xff0c;\u4f8b\u5982 journal\u3001null\u3001file: \u7b49\u3002<\/td>\n<\/tr>\n<tr>\n<td>StandardError<\/td>\n<td>\u6307\u5b9a\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u7684\u53bb\u5411\u3002<\/td>\n<\/tr>\n<tr>\n<td>SyslogIdentifier<\/td>\n<td>\u8bbe\u7f6e\u5199\u5165 journal \u65f6\u4f7f\u7528\u7684\u6807\u8bc6\u540d\u79f0\u3002<\/td>\n<\/tr>\n<tr>\n<td>Nice<\/td>\n<td>\u8bbe\u7f6e\u8fdb\u7a0b\u7684 CPU \u8c03\u5ea6\u4f18\u5148\u7ea7\u3002<\/td>\n<\/tr>\n<tr>\n<td>OOMScoreAdjust<\/td>\n<td>\u8c03\u6574\u8fdb\u7a0b\u88ab Linux OOM Killer \u6740\u6b7b\u65f6\u7684\u4f18\u5148\u7ea7\u3002<\/td>\n<\/tr>\n<tr>\n<td>LimitNOFILE<\/td>\n<td>\u9650\u5236\u8fdb\u7a0b\u80fd\u591f\u6253\u5f00\u7684\u6700\u5927\u6587\u4ef6\u63cf\u8ff0\u7b26\u6570\u91cf\u3002<\/td>\n<\/tr>\n<tr>\n<td>LimitNPROC<\/td>\n<td>\u9650\u5236\u8fdb\u7a0b\u80fd\u591f\u521b\u5efa\u7684\u8fdb\u7a0b\/\u7ebf\u7a0b\u6570\u91cf\u3002<\/td>\n<\/tr>\n<tr>\n<td>PrivateTmp<\/td>\n<td>\u4e3a\u670d\u52a1\u63d0\u4f9b\u72ec\u7acb\u7684 \/tmp \u548c \/var\/tmp \u73af\u5883\u3002<\/td>\n<\/tr>\n<tr>\n<td>ProtectSystem<\/td>\n<td>\u9650\u5236\u670d\u52a1\u5bf9\u7cfb\u7edf\u76ee\u5f55\u7684\u5199\u6743\u9650&#xff0c;\u63d0\u9ad8\u5b89\u5168\u6027\u3002<\/td>\n<\/tr>\n<tr>\n<td>ProtectHome<\/td>\n<td>\u9650\u5236\u670d\u52a1\u8bbf\u95ee \/home\u3001\/root\u3001\/run\/user \u7b49\u76ee\u5f55\u3002<\/td>\n<\/tr>\n<tr>\n<td>NoNewPrivileges<\/td>\n<td>\u7981\u6b62\u670d\u52a1\u8fdb\u7a0b\u901a\u8fc7 execve() \u83b7\u53d6\u65b0\u7684\u7279\u6743&#xff0c;\u63d0\u9ad8\u5b89\u5168\u6027\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7531\u4e8e Type \u662f [Service] \u4e2d\u975e\u5e38\u91cd\u8981\u7684\u53c2\u6570&#xff0c;\u56e0\u6b64\u4e0b\u9762\u5c06\u5bf9\u8be5\u53c2\u6570\u8fdb\u884c\u8be6\u7ec6\u8bf4\u660e&#xff1a;<\/p>\n<table>\n<tr>Type\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>simple<\/td>\n<td>ExecStart \u542f\u52a8\u7684\u8fdb\u7a0b\u5c31\u662f\u4e3b\u8fdb\u7a0b&#xff0c;systemd \u542f\u52a8\u547d\u4ee4\u540e\u901a\u5e38\u5c31\u8ba4\u4e3a\u670d\u52a1\u5df2\u7ecf\u542f\u52a8\u3002<\/td>\n<\/tr>\n<tr>\n<td>exec<\/td>\n<td>\u7c7b\u4f3c simple&#xff0c;\u4f46\u4f1a\u7b49\u5f85\u7a0b\u5e8f\u771f\u6b63\u6210\u529f\u6267\u884c\u540e\u518d\u8ba4\u4e3a\u542f\u52a8\u6210\u529f\u3002<\/td>\n<\/tr>\n<tr>\n<td>forking<\/td>\n<td>\u7a0b\u5e8f\u542f\u52a8\u540e\u4f1a fork \u5230\u540e\u53f0&#xff0c;\u4f20\u7edf\u5b88\u62a4\u8fdb\u7a0b\u5e38\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u3002<\/td>\n<\/tr>\n<tr>\n<td>oneshot<\/td>\n<td>\u6267\u884c\u4e00\u6b21\u547d\u4ee4\u540e\u9000\u51fa&#xff0c;\u5e38\u7528\u4e8e\u811a\u672c\u3001\u521d\u59cb\u5316\u4efb\u52a1\u3002<\/td>\n<\/tr>\n<tr>\n<td>notify<\/td>\n<td>\u7a0b\u5e8f\u901a\u8fc7 systemd \u7684\u901a\u77e5\u673a\u5236\u4e3b\u52a8\u544a\u8bc9 systemd \u201c\u6211\u5df2\u7ecf\u542f\u52a8\u5b8c\u6210\u201d\u3002<\/td>\n<\/tr>\n<tr>\n<td>dbus<\/td>\n<td>\u7a0b\u5e8f\u6210\u529f\u83b7\u5f97\u6307\u5b9a D-Bus \u540d\u79f0\u540e\u8ba4\u4e3a\u542f\u52a8\u5b8c\u6210\u3002<\/td>\n<\/tr>\n<tr>\n<td>idle<\/td>\n<td>\u7b49\u5f85\u5176\u4ed6\u4efb\u52a1\u5b8c\u6210\u540e\u518d\u542f\u52a8&#xff0c;\u4e3b\u8981\u7528\u4e8e\u8c03\u6574\u542f\u52a8\u65f6\u673a\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\n<p>   3.2\u3001Target<br \/>\n <\/h4>\n<p>\u5355\u5143\u4ecb\u7ecd&#xff1a;\u642d\u914d service \u6216\u5176\u4ed6\u7c7b\u578b\u7684 Unit \u4f7f\u7528&#xff0c;\u53ef\u4ee5\u7406\u89e3\u4e3a\u662f \u4e00\u7ec4 Unit \u7684\u96c6\u5408&#xff0c;\u5b83\u672c\u8eab\u901a\u5e38\u4e0d\u6267\u884c\u7a0b\u5e8f&#xff0c;\u800c\u662f\u7528\u6765\u7ec4\u7ec7\u548c\u63a7\u5236\u591a\u4e2a service\u3001mount\u3001socket \u7b49 Unit \u7684\u542f\u52a8\u987a\u5e8f\u3002<\/p>\n<p>\u671f\u671b\u76ee\u6807&#xff1a;\u901a\u8fc7\u4e00\u6761\u547d\u4ee4\u4fbf\u53ef\u540c\u65f6\u542f\u52a8\u8fd9\u4e9b web \u4e1a\u52a1\u670d\u52a1&#xff1a;nginx\u3001mysql\u3001redis\u3002<\/p>\n<p><span class=\"token comment\"># cat nginx.service mysql.service redis.service<\/span><br \/>\n<span class=\"token punctuation\">..<\/span>.\u7701\u7565<span class=\"token punctuation\">..<\/span>.<\/p>\n<p># cat myapp.target<\/p>\n<p>[Unit]<br \/>\nDescription&#061;My Application Stack<\/p>\n<p>Requires&#061;nginx.service mysql.service redis.service<\/p>\n<p>After&#061;nginx.service mysql.service redis.service<\/p>\n<p>\u3010Target \u5757\u3011\u5e38\u7528\u53c2\u6570\u5217\u8868&#xff1a;<\/p>\n<p>\u6ce8&#xff1a;\u8be5 Unit \u7684\u914d\u7f6e\u6587\u4ef6\u65e0\u4e13\u5c5e\u5757\u53c2\u6570&#xff0c;\u53ea\u9700\u8981\u901a\u7528\u7684 Unit\u3001Install \u5757\u5373\u53ef\u3002<\/p>\n<h4>\n<p>   3.3\u3001Timer<br \/>\n <\/h4>\n<p>\u5355\u5143\u4ecb\u7ecd&#xff1a;\u642d\u914d service \u4f7f\u7528&#xff0c;\u53ef\u4ee5\u7406\u89e3\u4e3a\u662f service \u7684\u4e13\u5c5e\u5b9a\u65f6\u5668&#xff0c;\u65f6\u95f4\u5355\u4f4d\u53ef\u7cbe\u7ec6\u5230\u79d2\u3002\u3010\u6ce8&#xff1a;cron \u7684\u6700\u5c0f\u65f6\u95f4\u5355\u4f4d\u662f\u5206\u949f\u3011<\/p>\n<p>\u671f\u671b\u76ee\u6807&#xff1a;\u5b9a\u65f6\u6267\u884c\u670d\u52a1\u7a0b\u5e8f\u3002<\/p>\n<p># cat backup.service<\/p>\n<p>[Unit]<br \/>\nDescription&#061;backup file <\/p>\n<p>[Service]<br \/>\nType&#061;oneshot<br \/>\nExecStart&#061;\/usr\/local\/bin\/file-backup.sh<\/p>\n<p># cat backup.timer<\/p>\n<p>[Unit]<br \/>\nDescription&#061;backup my server timer<\/p>\n<p>[Timer]<br \/>\nOnBootSec&#061;2hrs            # \u5f00\u673a\u540e 2 \u5c0f\u65f6\u5f00\u59cb\u6267\u884c\u4e00\u6b21\u8fd9\u4e2a backup.service\u3002<br \/>\nOnUnitActiveSec&#061;2days     # \u81ea\u4ece\u7b2c\u4e00\u6b21\u6267\u884c\u540e&#xff0c;\u672a\u6765\u6bcf\u4e24\u5929\u8981\u6267\u884c\u4e00\u6b21 backup.service\u3002<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p>\u6ce8&#xff1a;\u6301\u7eed\u8ba1\u65f6\u53c2\u6570\u3002<\/p>\n<p> # \u6bcf\u5929\u51cc\u6668\u6267\u884c\u5907\u4efd\u3002<br \/>\n[Timer]<br \/>\nOnCalendar&#061;*-*-* 02:00:00<br \/>\nPersistent&#061;true<\/p>\n<p>\u3010Timer \u5757\u3011\u5e38\u7528\u53c2\u6570\u5217\u8868&#xff1a;<\/p>\n<table>\n<tr>\u8bbe\u5b9a\u53c2\u6570\u53c2\u6570\u610f\u4e49\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>OnBootSec<\/td>\n<td>\u7cfb\u7edf\u542f\u52a8\u540e\u7ecf\u8fc7\u6307\u5b9a\u65f6\u95f4\u540e\u89e6\u53d1 Timer&#xff0c;\u4f8b\u5982 OnBootSec&#061;5min \u8868\u793a\u7cfb\u7edf\u542f\u52a8 5 \u5206\u949f\u540e\u6267\u884c\u3002<\/td>\n<\/tr>\n<tr>\n<td>OnStartupSec<\/td>\n<td>systemd \u7528\u6237\u5b9e\u4f8b\u6216\u7cfb\u7edf\u5b9e\u4f8b\u542f\u52a8\u540e\u7ecf\u8fc7\u6307\u5b9a\u65f6\u95f4\u89e6\u53d1\u3002\u7cfb\u7edf\u7ea7 Timer \u4e2d\u901a\u5e38\u4e0e OnBootSec \u7c7b\u4f3c\u3002<\/td>\n<\/tr>\n<tr>\n<td>OnUnitActiveSec<\/td>\n<td>\u88ab\u89e6\u53d1\u7684 Unit \u4e0a\u4e00\u6b21\u88ab\u6fc0\u6d3b\u540e&#xff0c;\u7ecf\u8fc7\u6307\u5b9a\u65f6\u95f4\u518d\u6b21\u89e6\u53d1\u3002\u4f8b\u5982 OnUnitActiveSec&#061;1h \u8868\u793a\u670d\u52a1\u6fc0\u6d3b\u540e\u6bcf\u9694 1 \u5c0f\u65f6\u518d\u6b21\u89e6\u53d1\u3002<\/td>\n<\/tr>\n<tr>\n<td>OnUnitInactiveSec<\/td>\n<td>\u88ab\u89e6\u53d1\u7684 Unit \u53d8\u4e3a inactive \u540e&#xff0c;\u7ecf\u8fc7\u6307\u5b9a\u65f6\u95f4\u518d\u6b21\u89e6\u53d1\u3002<\/td>\n<\/tr>\n<tr>\n<td>OnCalendar<\/td>\n<td>\u6309\u65e5\u5386\u65f6\u95f4\u89e6\u53d1&#xff0c;\u4f8b\u5982 OnCalendar&#061;daily\u3001OnCalendar&#061;*-*-* 02:00:00\u3002<\/td>\n<\/tr>\n<tr>\n<td>OnActiveSec<\/td>\n<td>Timer \u672c\u8eab\u88ab\u6fc0\u6d3b\u540e\u7ecf\u8fc7\u6307\u5b9a\u65f6\u95f4\u89e6\u53d1\u3002<\/td>\n<\/tr>\n<tr>\n<td>OnFailureSec<\/td>\n<td>Timer \u6240\u5173\u8054\u7684 Unit \u5931\u8d25\u540e\u7ecf\u8fc7\u6307\u5b9a\u65f6\u95f4\u89e6\u53d1\u3002<\/td>\n<\/tr>\n<tr>\n<td>Persistent<\/td>\n<td>\u662f\u5426\u8865\u6267\u884c\u9519\u8fc7\u7684\u4efb\u52a1\u3002\u8bbe\u7f6e\u4e3a true \u540e&#xff0c;\u5982\u679c\u673a\u5668\u5173\u673a\u671f\u95f4\u9519\u8fc7\u4e86\u5b9a\u65f6\u4efb\u52a1&#xff0c;\u4e0b\u4e00\u6b21\u542f\u52a8\u65f6\u4f1a\u8865\u6267\u884c\u3002<\/td>\n<\/tr>\n<tr>\n<td>AccuracySec<\/td>\n<td>Timer \u89e6\u53d1\u65f6\u95f4\u5141\u8bb8\u7684\u8bef\u5dee\u8303\u56f4&#xff0c;\u7528\u4e8e\u8ba9 systemd \u5408\u5e76\u591a\u4e2a\u5b9a\u65f6\u4efb\u52a1\u4ee5\u51cf\u5c11\u7cfb\u7edf\u5524\u9192\u3002<\/td>\n<\/tr>\n<tr>\n<td>RandomizedDelaySec<\/td>\n<td>\u5728\u8ba1\u5212\u89e6\u53d1\u65f6\u95f4\u57fa\u7840\u4e0a\u589e\u52a0\u968f\u673a\u5ef6\u8fdf&#xff0c;\u53ef\u907f\u514d\u5927\u91cf\u673a\u5668\u540c\u65f6\u6267\u884c\u4efb\u52a1\u3002<\/td>\n<\/tr>\n<tr>\n<td>Unit<\/td>\n<td>\u6307\u5b9a Timer \u89e6\u53d1\u54ea\u4e2a Unit\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;xxx.timer \u901a\u5e38\u89e6\u53d1\u540c\u540d\u7684 xxx.service\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\n<p>   3.4\u3001Path<br \/>\n <\/h4>\n<p>\u5355\u5143\u4ecb\u7ecd&#xff1a;\u642d\u914d service \u4f7f\u7528&#xff0c;\u5f53\u67d0\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\/\u72b6\u6001\u51fa\u73b0\u53d8\u52a8\u65f6&#xff0c;\u89e6\u53d1\u5bf9\u7ed1\u5b9a service \u7684\u542f\u52a8\u3002<\/p>\n<p>\u671f\u671b\u76ee\u6807&#xff1a;\u5f53\u6587\u4ef6 \/tmp\/test.txt \u88ab\u4fee\u6539&#xff08;echo hello &gt;&gt; \/tmp\/test.txt&#xff09;\u65f6&#xff0c;\u7cfb\u7edf\u4f1a\u81ea\u52a8\u6267\u884c file-change.sh \u811a\u672c\u3002<\/p>\n<p># cat file-change.service<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Handle file change<\/p>\n<p>[Service]<br \/>\nType&#061;oneshot<br \/>\nExecStart&#061;\/usr\/local\/bin\/file-change.sh<\/p>\n<p># cat file-change.path<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Monitor test file<\/p>\n<p>[Path]<br \/>\nPathModified&#061;\/tmp\/test.txt<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p>\u3010Path \u5757\u3011\u5e38\u7528\u53c2\u6570\u5217\u8868&#xff1a;<\/p>\n<table>\n<tr>\u8bbe\u5b9a\u53c2\u6570\u53c2\u6570\u610f\u4e49\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>PathExists<\/td>\n<td>\u6307\u5b9a\u8def\u5f84\u5b58\u5728\u65f6\u89e6\u53d1\u5173\u8054\u7684 Service\u3002<\/td>\n<\/tr>\n<tr>\n<td>PathExistsGlob<\/td>\n<td>\u4f7f\u7528\u901a\u914d\u7b26\u5339\u914d\u8def\u5f84&#xff0c;\u53ea\u8981\u5339\u914d\u7684\u8def\u5f84\u5b58\u5728\u5c31\u89e6\u53d1 Service\u3002<\/td>\n<\/tr>\n<tr>\n<td>PathChanged<\/td>\n<td>\u6307\u5b9a\u6587\u4ef6\u6216\u76ee\u5f55\u53d1\u751f\u53d8\u5316\u65f6\u89e6\u53d1 Service\u3002<\/td>\n<\/tr>\n<tr>\n<td>PathModified<\/td>\n<td>\u6307\u5b9a\u6587\u4ef6\u88ab\u4fee\u6539\u65f6\u89e6\u53d1 Service\u3002\u76f8\u6bd4 PathChanged&#xff0c;\u66f4\u5173\u6ce8\u6587\u4ef6\u5185\u5bb9\u4fee\u6539\u3002<\/td>\n<\/tr>\n<tr>\n<td>DirectoryNotEmpty<\/td>\n<td>\u6307\u5b9a\u76ee\u5f55\u4e0d\u4e3a\u7a7a\u65f6\u89e6\u53d1 Service&#xff0c;\u5e38\u7528\u4e8e\u76d1\u63a7\u201c\u6587\u4ef6\u6295\u9012\u76ee\u5f55\u201d\u3002<\/td>\n<\/tr>\n<tr>\n<td>Unit<\/td>\n<td>\u6307\u5b9a Path Unit \u89e6\u53d1\u54ea\u4e2a Unit\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;xxx.path \u901a\u5e38\u89e6\u53d1\u540c\u540d\u7684 xxx.service\u3002<\/td>\n<\/tr>\n<tr>\n<td>MakeDirectory<\/td>\n<td>\u521b\u5efa\u76d1\u63a7\u8def\u5f84\u4e0d\u5b58\u5728\u7684\u7236\u76ee\u5f55\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\n<p>   3.5\u3001Slice<br \/>\n <\/h4>\n<p>\u5355\u5143\u4ecb\u7ecd&#xff1a;\u642d\u914d service \u4f7f\u7528&#xff0c;\u8ba9\u52a0\u5165\u5230\u540c\u4e00\u4e2a\u8d44\u6e90\u7ec4\u7684\u670d\u52a1\u5171\u7528\u540c\u4e00\u4e2a\u73af\u5883\u7684\u8d44\u6e90&#xff0c;\u53ef\u4ee5\u8d77\u5230\u9650\u5236\u8fdb\u7a0b\u65e0\u9650\u4f7f\u7528\u7cfb\u7edf\u8d44\u6e90\u7684\u4f5c\u7528\u3002<\/p>\n<p>\u671f\u671b\u76ee\u6807&#xff1a;\u8ba9 nginx \u670d\u52a1\u6240\u80fd\u4f7f\u7528\u7684\u6700\u5927 CPU \u4e0d\u8d85\u8fc7 40%&#xff0c;\u6700\u5927\u5185\u5b58\u4e0d\u8d85\u8fc7 2G\u3002<\/p>\n<p># cat nginx.service<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Nginx Web Server<br \/>\nAfter&#061;network.target<\/p>\n<p>[Service]<br \/>\nExecStart&#061;\/usr\/sbin\/nginx<br \/>\nExecStop&#061;\/usr\/sbin\/nginx -s stop<br \/>\nRestart&#061;always<br \/>\nSlice&#061;web.slice<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p># cat web.slice<\/p>\n<p>[Slice]<br \/>\nCPUQuota&#061;40%<br \/>\nMemoryMax&#061;2G<\/p>\n<p>\u3010Slice \u5757\u3011\u5e38\u7528\u53c2\u6570\u5217\u8868&#xff1a;<\/p>\n<table>\n<tr>\u8bbe\u5b9a\u53c2\u6570\u53c2\u6570\u610f\u4e49\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>CPUQuota<\/td>\n<td>\u9650\u5236\u8be5 Slice \u6700\u591a\u4f7f\u7528\u591a\u5c11 CPU&#xff0c;\u4f8b\u5982 CPUQuota&#061;50% \u8868\u793a\u6700\u591a\u4f7f\u7528 50% \u7684\u4e00\u4e2a CPU \u6838\u5fc3\u3002<\/td>\n<\/tr>\n<tr>\n<td>MemoryMax<\/td>\n<td>\u8bbe\u7f6e\u8be5 Slice \u53ef\u4f7f\u7528\u7684\u6700\u5927\u5185\u5b58&#xff0c;\u8d85\u8fc7\u9650\u5236\u540e\u53ef\u80fd\u89e6\u53d1 OOM \u5904\u7406\u3002<\/td>\n<\/tr>\n<tr>\n<td>MemoryHigh<\/td>\n<td>\u8bbe\u7f6e\u5185\u5b58\u4f7f\u7528\u7684\u201c\u9ad8\u6c34\u4f4d\u201d&#xff0c;\u8d85\u8fc7\u540e systemd \u4f1a\u5bf9\u8be5 Slice \u65bd\u52a0\u5185\u5b58\u538b\u529b\u63a7\u5236&#xff0c;\u4f46\u901a\u5e38\u4e0d\u4f1a\u50cf MemoryMax \u90a3\u6837\u76f4\u63a5\u4f5c\u4e3a\u786c\u9650\u5236\u3002<\/td>\n<\/tr>\n<tr>\n<td>MemoryMin<\/td>\n<td>\u8bbe\u7f6e\u8be5 Slice \u5e94\u83b7\u5f97\u7684\u6700\u4f4e\u5185\u5b58\u4fdd\u969c\u3002<\/td>\n<\/tr>\n<tr>\n<td>MemoryLow<\/td>\n<td>\u8bbe\u7f6e\u5185\u5b58\u4fdd\u62a4\u7684\u4f4e\u6c34\u4f4d\u3002<\/td>\n<\/tr>\n<tr>\n<td>TasksMax<\/td>\n<td>\u9650\u5236\u8be5 Slice \u4e2d\u6700\u591a\u5141\u8bb8\u521b\u5efa\u591a\u5c11\u4e2a\u8fdb\u7a0b\/\u7ebf\u7a0b\u3002<\/td>\n<\/tr>\n<tr>\n<td>IOWeight<\/td>\n<td>\u8bbe\u7f6e\u78c1\u76d8 I\/O \u6743\u91cd&#xff0c;\u7528\u4e8e\u4e0d\u540c Slice \u4e4b\u95f4\u7684 I\/O \u8d44\u6e90\u7ade\u4e89\u3002<\/td>\n<\/tr>\n<tr>\n<td>IODeviceWeight<\/td>\n<td>\u9488\u5bf9\u7279\u5b9a\u8bbe\u5907\u8bbe\u7f6e I\/O \u6743\u91cd\u3002<\/td>\n<\/tr>\n<tr>\n<td>BlockIOAccounting<\/td>\n<td>\u662f\u5426\u7edf\u8ba1\u8be5 Slice \u7684\u5757\u8bbe\u5907 I\/O \u4f7f\u7528\u60c5\u51b5\u3002<\/td>\n<\/tr>\n<tr>\n<td>CPUAccounting<\/td>\n<td>\u662f\u5426\u7edf\u8ba1 CPU \u4f7f\u7528\u60c5\u51b5\u3002<\/td>\n<\/tr>\n<tr>\n<td>MemoryAccounting<\/td>\n<td>\u662f\u5426\u7edf\u8ba1\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002<\/td>\n<\/tr>\n<tr>\n<td>TasksAccounting<\/td>\n<td>\u662f\u5426\u7edf\u8ba1\u4efb\u52a1\u6570\u91cf\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\n<p>   3.6\u3001Mount<br \/>\n <\/h4>\n<p>\u5355\u5143\u4ecb\u7ecd&#xff1a;\u8be5 Unit \u76f8\u5f53\u4e8e\u662f\u5bf9\u7cfb\u7edf fatab\/mount \u7684\u53e6\u4e00\u79cd\u5b9e\u73b0&#xff0c;\u540c\u65f6\u4e5f\u662f Automount \u81ea\u52a8\u6302\u8f7d\u5355\u5143\u7684\u57fa\u672c Unit\u3002<\/p>\n<p>\u671f\u671b\u76ee\u6807&#xff1a;\u901a\u8fc7 systemctl start data.mount \u5c06 sdb1 \u8fd9\u4e2a\u5206\u533a\u6302\u8f7d\u5230 \/data \u76ee\u5f55\u4e0b\u3002<\/p>\n<p># cat data.mount<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Mount data disk<\/p>\n<p>[Mount]<br \/>\nWhat&#061;\/dev\/sdb1<br \/>\nWhere&#061;\/data<br \/>\nType&#061;ext4<br \/>\nOptions&#061;defaults<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p>\u3010Mount \u5757\u3011\u5e38\u7528\u53c2\u6570\u5217\u8868&#xff1a;<\/p>\n<table>\n<tr>\u8bbe\u5b9a\u53c2\u6570\u53c2\u6570\u610f\u4e49\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>What<\/td>\n<td>\u6307\u5b9a\u8981\u6302\u8f7d\u7684\u8bbe\u5907\u3001\u78c1\u76d8\u5206\u533a\u3001LVM\u3001NFS \u7b49\u6765\u6e90&#xff0c;\u4f8b\u5982 \/dev\/sdb1\u3002<\/td>\n<\/tr>\n<tr>\n<td>Where<\/td>\n<td>\u6307\u5b9a\u6302\u8f7d\u70b9&#xff0c;\u4f8b\u5982 \/data\u3002\u8fd9\u662f Mount Unit \u6700\u6838\u5fc3\u7684\u53c2\u6570\u4e4b\u4e00\u3002<\/td>\n<\/tr>\n<tr>\n<td>Type<\/td>\n<td>\u6307\u5b9a\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b&#xff0c;\u4f8b\u5982 ext4\u3001xfs\u3001nfs \u7b49\u3002<\/td>\n<\/tr>\n<tr>\n<td>Options<\/td>\n<td>\u6307\u5b9a\u6302\u8f7d\u53c2\u6570&#xff0c;\u76f8\u5f53\u4e8e mount -o \u540e\u9762\u7684\u53c2\u6570&#xff0c;\u4f8b\u5982 defaults,noatime\u3002<\/td>\n<\/tr>\n<tr>\n<td>SloppyOptions<\/td>\n<td>\u662f\u5426\u5141\u8bb8\u90e8\u5206\u65e0\u6cd5\u8bc6\u522b\u7684\u6302\u8f7d\u9009\u9879\u88ab\u5ffd\u7565\u3002<\/td>\n<\/tr>\n<tr>\n<td>LazyUnmount<\/td>\n<td>Unit \u505c\u6b62\u65f6\u662f\u5426\u4f7f\u7528 lazy unmount\u3002<\/td>\n<\/tr>\n<tr>\n<td>ForceUnmount<\/td>\n<td>Unit \u505c\u6b62\u65f6\u662f\u5426\u5f3a\u5236\u5378\u8f7d\u3002<\/td>\n<\/tr>\n<tr>\n<td>DirectoryMode<\/td>\n<td>\u5982\u679c\u6302\u8f7d\u70b9\u76ee\u5f55\u4e0d\u5b58\u5728&#xff0c;\u6307\u5b9a\u521b\u5efa\u76ee\u5f55\u65f6\u4f7f\u7528\u7684\u6743\u9650\u3002<\/td>\n<\/tr>\n<tr>\n<td>TimeoutSec<\/td>\n<td>\u8bbe\u7f6e\u6302\u8f7d\u64cd\u4f5c\u7684\u8d85\u65f6\u65f6\u95f4\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\n<p>   3.7\u3001Automount<br \/>\n <\/h4>\n<p>\u5355\u5143\u4ecb\u7ecd&#xff1a;\u642d\u914d mount \u5355\u5143\u4f7f\u7528&#xff0c;\u5f53\u6307\u5b9a\u7684\u76ee\u5f55\u88ab\u8bfb\u53d6\u65f6&#xff0c;\u81ea\u52a8\u89e6\u53d1\u5bf9\u7ed1\u5b9a mount \u7684\u542f\u52a8\u3002<\/p>\n<p>\u671f\u671b\u76ee\u6807&#xff1a;\u6b63\u5e38\u60c5\u51b5\u4e0b&#xff0c;backup.mount \u8fd9\u4e2a\u5206\u533a\u5e76\u4e0d\u4f1a\u88ab\u6302\u8f7d&#xff0c;\u4f46\u662f\u5f53\u6267\u884c ls \/backup \u7684\u65f6\u5019&#xff0c;\u8fd9\u4e2a\u5206\u533a\u624d\u4f1a\u88ab\u6302\u8f7d\u3002<\/p>\n<p># cat backup.mount<\/p>\n<p>[Unit]<br \/>\nDescription&#061;NFS Backup Mount<\/p>\n<p>[Mount]<br \/>\nWhat&#061;192.168.1.10:\/backup<br \/>\nWhere&#061;\/backup<br \/>\nType&#061;nfs<br \/>\nOptions&#061;defaults<\/p>\n<p># \u6ce8\u610f&#xff0c;\u8fd9\u91cc\u6ca1\u6709\u914d\u7f6e WantedBy&#061; \u9009\u9879&#xff0c;\u56e0\u4e3a\u5b83\u4e0d\u9700\u8981\u901a\u8fc7\u5f00\u673a\u542f\u52a8\u3002<\/p>\n<p># cat backup.automount<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Automount backup directory<\/p>\n<p>[Automount]<br \/>\nWhere&#061;\/backup<br \/>\nTimeoutIdleSec&#061;300<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<\/p>\n<p>\u6ce8&#xff1a;mount \u4e00\u822c\u7528\u4e8e\u5f00\u673a\u81ea\u542f&#xff0c;\u800c automount \u5219\u7528\u4e8e\u6309\u9700\u81ea\u542f\u3002<\/p>\n<p>\u3010Automount \u5757\u3011\u5e38\u7528\u53c2\u6570\u5217\u8868&#xff1a;<\/p>\n<table>\n<tr>\u8bbe\u5b9a\u53c2\u6570\u53c2\u6570\u610f\u4e49\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>Where<\/td>\n<td>\u6307\u5b9a\u81ea\u52a8\u6302\u8f7d\u70b9&#xff0c;\u4f8b\u5982 \/data\u3002<\/td>\n<\/tr>\n<tr>\n<td>DirectoryMode<\/td>\n<td>\u5982\u679c\u6302\u8f7d\u70b9\u76ee\u5f55\u4e0d\u5b58\u5728&#xff0c;\u6307\u5b9a\u521b\u5efa\u76ee\u5f55\u65f6\u7684\u6743\u9650\u3002<\/td>\n<\/tr>\n<tr>\n<td>TimeoutIdleSec<\/td>\n<td>\u6307\u5b9a\u6302\u8f7d\u70b9\u7a7a\u95f2\u591a\u957f\u65f6\u95f4\u540e\u81ea\u52a8\u5378\u8f7d\u3002\u4f8b\u5982 TimeoutIdleSec&#061;10min\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\n<p>   4\u3001\u547d\u4ee4\u7ba1\u7406<br \/>\n <\/h3>\n<h4>\n<p>   4.1\u3001systemctl \u547d\u4ee4\u7528\u6cd5<br \/>\n <\/h4>\n<p>systemd \u7528\u6765\u7ba1\u7406\u670d\u52a1\u7684\u547d\u4ee4\u53ea\u6709\u4e00\u6761&#xff0c;\u5373 systemctl&#xff0c;\u4ee5\u4e0b\u4fbf\u662f\u5173\u4e8e\u8be5\u547d\u4ee4\u6700\u5e38\u89c1\u7684\u7528\u6cd5&#xff1a;<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 1. \u670d\u52a1\u7ba1\u7406 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u542f\u52a8\/\u505c\u6b62\/\u91cd\u542f\/\u91cd\u8f7d\/\u67e5\u770b\u670d\u52a1<\/span><br \/>\nsystemctl start\/stop\/restart\/reload\/status nginx<\/p>\n<p><span class=\"token comment\"># \u8bbe\u7f6e\/\u53d6\u6d88\/\u5f00\u673a\u81ea\u542f&#xff0c;\u4ee5\u53ca\u7981\u6b62\/\u53d6\u6d88\u7981\u6b62\u670d\u52a1\u88ab\u81ea\u542f<\/span><br \/>\nsystemctl enable\/disable\/mask\/unmask nginx<\/p>\n<p><span class=\"token comment\"># \u5224\u65ad\u670d\u52a1 \u662f\u5426\u81ea\u542f\/\u662f\u5426\u6b63\u5728\u8fd0\u884c\/\u662f\u5426\u542f\u52a8\u5931\u8d25<\/span><br \/>\nsystemctl is-enabled\/is-active\/is-failed nginx<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2. \u670d\u52a1\u72b6\u6001\u67e5\u770b &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u7cfb\u7edf\u4e2d\u6240\u6709\u5df2\u5b89\u88c5\u7684 Unit \u6587\u4ef6\u7684\u9884\u8bbe\u72b6\u6001<\/span><br \/>\nsystemctl list-unit-files<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6240\u6709 Unit \u7684\u8fd0\u884c\u72b6\u6001&#xff0c;\u5305\u62ec inactive<\/span><br \/>\nsystemctl list-units <span class=\"token parameter variable\">&#8211;all<\/span><\/p>\n<p><span class=\"token comment\"># \u6309 Unit \u7c7b\u578b\u67e5\u770b\u5f53\u524d\u542f\u52a8\u7684 Unit<\/span><br \/>\nsystemctl list-units <span class=\"token parameter variable\">&#8211;type<\/span><span class=\"token operator\">&#061;<\/span>service<br \/>\nsystemctl list-units <span class=\"token parameter variable\">&#8211;type<\/span><span class=\"token operator\">&#061;<\/span>socket<br \/>\nsystemctl list-units <span class=\"token parameter variable\">&#8211;type<\/span><span class=\"token operator\">&#061;<\/span>timer<br \/>\nsystemctl list-units <span class=\"token parameter variable\">&#8211;type<\/span><span class=\"token operator\">&#061;<\/span>mount<br \/>\nsystemctl list-units <span class=\"token parameter variable\">&#8211;type<\/span><span class=\"token operator\">&#061;<\/span>target<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u542f\u52a8\u5931\u8d25\u7684 Unit<\/span><br \/>\nsystemctl list-units <span class=\"token parameter variable\">&#8211;state<\/span><span class=\"token operator\">&#061;<\/span>failed  <span class=\"token comment\"># \u7b49\u4ef7\u4e8e systemctl &#8211;failed<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6240\u6709 Socket \u670d\u52a1\u7684\u72b6\u6001&#xff0c;\u4e0d\u8bba\u662f\u5426\u542f\u52a8<\/span><br \/>\nsystemctl list-sockets<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6240\u6709 Timer \u670d\u52a1\u7684\u72b6\u6001&#xff0c;\u4e0d\u8bba\u662f\u5426\u542f\u52a8<\/span><br \/>\nsystemctl list-timers<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6240\u6709 Path \u670d\u52a1\u7684\u72b6\u6001&#xff0c;\u4e0d\u8bba\u662f\u5426\u542f\u52a8<\/span><br \/>\nsystemctl list-paths<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6240\u6709 Automount \u670d\u52a1\u7684\u72b6\u6001&#xff0c;\u4e0d\u8bba\u662f\u5426\u542f\u52a8<\/span><br \/>\nsystemctl list-automounts<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 3. Unit \u6587\u4ef6\u7ba1\u7406 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b Unit \u7684\u5c5e\u6027\u4fe1\u606f<\/span><br \/>\nsystemctl show nginx<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b Unit \u6587\u4ef6\u5185\u5bb9<\/span><br \/>\nsystemctl <span class=\"token function\">cat<\/span> nginx<\/p>\n<p><span class=\"token comment\"># \u7f16\u8f91 Unit \u6587\u4ef6&#xff08;\u4fee\u6539\u5185\u5bb9\u4f1a\u88ab\u6dfb\u52a0\u5230 \/etc\/systemd\/system\/nginx.service.d\/override.conf \u6587\u4ef6\u4e2d&#xff09;<\/span><br \/>\nsystemctl edit nginx<\/p>\n<p><span class=\"token comment\"># \u7f16\u8f91\u5b8c\u6574 Unit \u6587\u4ef6&#xff08;\u53ef\u76f4\u63a5\u5728\u539f\u6765\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u4fee\u6539&#xff09;<\/span><br \/>\nsystemctl edit <span class=\"token parameter variable\">&#8211;full<\/span> nginx<\/p>\n<p><span class=\"token comment\"># \u4fee\u6539 Unit \u6587\u4ef6\u540e\u91cd\u65b0\u52a0\u8f7d systemd<\/span><br \/>\nsystemctl daemon-reload<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 4. Unit \u4f9d\u8d56\u67e5\u8be2 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b Unit \u7684\u4f9d\u8d56\u5173\u7cfb<\/span><br \/>\nsystemctl list-dependencies nginx<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u53cd\u5411\u4f9d\u8d56<\/span><br \/>\nsystemctl list-dependencies <span class=\"token parameter variable\">&#8211;reverse<\/span> nginx<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 5. Target \u7ba1\u7406 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u9ed8\u8ba4 Target<\/span><br \/>\nsystemctl get-default<\/p>\n<p><span class=\"token comment\"># \u8bbe\u7f6e\u9ed8\u8ba4 Target<\/span><br \/>\nsystemctl set-default multi-user.target<\/p>\n<p><span class=\"token comment\"># \u5207\u6362\u5230\u6307\u5b9a Target<\/span><br \/>\nsystemctl isolate multi-user.target<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b Target \u7684\u4f9d\u8d56<\/span><br \/>\nsystemctl list-dependencies multi-user.target<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 6. \u7cfb\u7edf\u64cd\u4f5c &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u91cd\u542f\u7cfb\u7edf<\/span><br \/>\nsystemctl <span class=\"token function\">reboot<\/span><\/p>\n<p><span class=\"token comment\"># \u5173\u673a<\/span><br \/>\nsystemctl poweroff<\/p>\n<p><span class=\"token comment\"># \u6302\u8d77<\/span><br \/>\nsystemctl <span class=\"token function\">suspend<\/span><\/p>\n<p><span class=\"token comment\"># \u4f11\u7720<\/span><br \/>\nsystemctl hibernate<\/p>\n<p><span class=\"token comment\"># \u8fdb\u5165\u6551\u63f4\u6a21\u5f0f<\/span><br \/>\nsystemctl rescue<\/p>\n<p><span class=\"token comment\"># \u8fdb\u5165\u7d27\u6025\u6a21\u5f0f<\/span><br \/>\nsystemctl emergency<\/p>\n<h4>\n<p>   4.2\u3001journalctl \u547d\u4ee4\u7528\u6cd5<br \/>\n <\/h4>\n<p>\u524d\u9762\u6211\u4eec\u8bf4\u8fc7&#xff0c;systemd \u4e0d\u4ec5\u53ef\u4ee5\u7528\u6765\u7ba1\u7406\u670d\u52a1&#xff0c;\u540c\u65f6\u5b83\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u65e5\u5fd7\u8bb0\u5f55\u670d\u52a1 journald \u6765\u8bb0\u5f55\u670d\u52a1\u5355\u5143\u7684\u65e5\u5fd7\u6d3b\u52a8&#xff0c;\u800c\u67e5\u770b\u65e5\u5fd7\u7684\u547d\u4ee4\u4e5f\u53ea\u6709\u4e00\u6761&#xff0c;\u5373 journalctl&#xff0c;\u4ee5\u4e0b\u4fbf\u662f\u5173\u4e8e\u8be5\u547d\u4ee4\u6700\u5e38\u89c1\u7684\u7528\u6cd5&#xff1a;<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 1. \u67e5\u770b\u65e5\u5fd7 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u5168\u90e8\u65e5\u5fd7<\/span><br \/>\njournalctl<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u5f53\u524d\u542f\u52a8\u7684\u5185\u6838\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-k<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6307\u5b9a\u670d\u52a1\u7684\u5168\u90e8\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-u<\/span> nginx<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6700\u8fd1 N \u6761\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-n<\/span> <span class=\"token number\">50<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6700\u65b0\u65e5\u5fd7\u5e76\u81ea\u52a8\u8df3\u5230\u672b\u5c3e<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-e<\/span><\/p>\n<p><span class=\"token comment\"># \u5b9e\u65f6\u8ddf\u8e2a\u65e5\u5fd7&#xff08;\u7c7b\u4f3c tail -f&#xff09;<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-f<\/span><\/p>\n<p><span class=\"token comment\"># \u663e\u793a\u5b8c\u6574\u65f6\u95f4\u7b49\u4fe1\u606f<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-o<\/span> short-full<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2. \u6309\u65f6\u95f4\u67e5\u770b\u65e5\u5fd7 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u4eca\u5929\u7684\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">&#8211;since<\/span> today<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6700\u8fd1 30 \u5206\u949f\u7684\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">&#8211;since<\/span> <span class=\"token string\">&#034;30 min ago&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6307\u5b9a\u65f6\u95f4\u4e4b\u540e\u7684\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">&#8211;since<\/span> <span class=\"token string\">&#034;2026-08-11 10:00:00&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6307\u5b9a\u65f6\u95f4\u4e4b\u524d\u7684\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">&#8211;until<\/span> <span class=\"token string\">&#034;2026-08-11 12:00:00&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u6307\u5b9a\u65f6\u95f4\u8303\u56f4\u7684\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">&#8211;since<\/span> <span class=\"token string\">&#034;2026-08-11 10:00:00&#034;<\/span> <span class=\"token parameter variable\">&#8211;until<\/span> <span class=\"token string\">&#034;2026-08-11 12:00:00&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u67d0\u670d\u52a1\u6700\u8fd1 1 \u5c0f\u65f6\u7684\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-u<\/span> nginx <span class=\"token parameter variable\">&#8211;since<\/span> today<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 3. \u6309\u65e5\u5fd7\u7ea7\u522b\u8fc7\u6ee4 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b error \u53ca\u66f4\u4e25\u91cd\u7684\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-p<\/span> err<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b warning \u5230 emergency<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-p<\/span> warning<span class=\"token punctuation\">..<\/span>emerg<\/p>\n<p><span class=\"token comment\"># \u5e38\u89c1\u65e5\u5fd7\u7ea7\u522b&#xff1a;<\/span><br \/>\n<span class=\"token comment\">#<\/span><br \/>\n<span class=\"token comment\">#   0  emerg    \u7d27\u6025<\/span><br \/>\n<span class=\"token comment\">#   1  alert    \u5fc5\u987b\u7acb\u5373\u5904\u7406<\/span><br \/>\n<span class=\"token comment\">#   2  crit     \u4e25\u91cd\u9519\u8bef<\/span><br \/>\n<span class=\"token comment\">#   3  err      \u9519\u8bef<\/span><br \/>\n<span class=\"token comment\">#   4  warning  \u8b66\u544a<\/span><br \/>\n<span class=\"token comment\">#   5  notice   \u6ce8\u610f<\/span><br \/>\n<span class=\"token comment\">#   6  info     \u4fe1\u606f<\/span><br \/>\n<span class=\"token comment\">#   7  debug    \u8c03\u8bd5<\/span><\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 4. \u6309\u5173\u952e\u8bcd\u641c\u7d22 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u641c\u7d22\u5305\u542b\u5173\u952e\u5b57\u7684\u65e5\u5fd7<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-g<\/span> <span class=\"token string\">&#034;error&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u641c\u7d22\u6307\u5b9a\u670d\u52a1\u4e2d\u7684\u5173\u952e\u8bcd<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-u<\/span> nginx <span class=\"token parameter variable\">-g<\/span> <span class=\"token string\">&#034;error&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u5ffd\u7565\u5927\u5c0f\u5199\u641c\u7d22<\/span><br \/>\njournalctl <span class=\"token parameter variable\">-g<\/span> <span class=\"token string\">&#034;error&#034;<\/span> &#8211;case-sensitive<span class=\"token operator\">&#061;<\/span>false<\/p>\n<p><span class=\"token comment\"># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 5. \u65e5\u5fd7\u7a7a\u95f4\u5360\u7528 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span class=\"token comment\"># \u67e5\u770b journal \u65e5\u5fd7\u5360\u7528\u7a7a\u95f4<\/span><br \/>\njournalctl &#8211;disk-usage<\/p>\n<p><span class=\"token comment\"># \u5220\u9664\u8d85\u8fc7\u6307\u5b9a\u65f6\u95f4\u7684\u65e5\u5fd7<\/span><br \/>\njournalctl &#8211;vacuum-time<span class=\"token operator\">&#061;<\/span>30d<\/p>\n<h3>\n<p>   5\u3001\u6742\u4e03\u6742\u516b<br \/>\n <\/h3>\n<p>&#xff08;1&#xff09;\u53c2\u8003\u6587\u6863&#xff1a;\u962e\u4e00\u5cf0\u7684\u7f51\u7edc\u65e5\u5fd7\u3001ArchWiki\u3001\u5b98\u65b9\u624b\u518c<\/p>\n<p>&#xff08;2&#xff09;systemctl \u5b50\u547d\u4ee4 daemon-reload \u548c reload \u7684\u533a\u522b &#xff1a;<\/p>\n<table>\n<tr>\u547d\u4ee4\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>systemctl daemon-reload<\/td>\n<td>\u8ba9 systemd \u91cd\u65b0\u8bfb\u53d6 Unit \u914d\u7f6e\u6587\u4ef6&#xff0c;\u4ee5\u4fbf systemctl \u5728\u7ba1\u7406\u670d\u52a1\u7684\u65f6\u5019\u80fd\u591f\u6309\u7167\u6700\u65b0\u7684 Unit \u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u505a\u51fa\u53cd\u5e94\u3002<\/td>\n<\/tr>\n<tr>\n<td>systemctl reload nginx.service<\/td>\n<td>\u8ba9\u67d0\u4e2a\u6b63\u5728\u8fd0\u884c\u7684\u670d\u52a1\u91cd\u65b0\u52a0\u8f7d\u81ea\u5df1\u7684\u914d\u7f6e\u6587\u4ef6&#xff0c;\u4f8b\u5982&#xff1a;\u8ba9 nginx \u670d\u52a1\u91cd\u65b0\u52a0\u8f7d\u81ea\u5df1\u7684\u914d\u7f6e\u6587\u4ef6 nginx.conf \u7684\u53c2\u6570\u5185\u5bb9\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#xff08;3&#xff09;\u4e3a\u4ec0\u4e48\u6267\u884c\u5f00\u673a\u81ea\u542f\u547d\u4ee4 systemctl enable *.service \u7684\u65f6\u5019&#xff0c;\u547d\u4ee4\u4f1a\u5728 \/etc\/systemd\/system\/multi-user.target.wants\/ \u76ee\u5f55\u4e2d\u6dfb\u52a0\u670d\u52a1\u7684\u8f6f\u94fe\u63a5&#xff1f;<\/p>\n<p>\u5f00\u673a\u81ea\u542f\u8bf4\u767d\u4e86\u5c31\u662f\u8ba9\u670d\u52a1\u80fd\u591f\u8ddf\u968f multi-user.target \u670d\u52a1\u5355\u5143\u4e00\u8d77\u88ab\u542f\u52a8&#xff0c;\u800c\u5728\u670d\u52a1\u5355\u5143 Unit \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d&#xff0c;\u8fd9\u4e00\u529f\u80fd\u662f\u53ef\u4ee5\u901a\u8fc7\u53c2\u6570 Wants \u5b9e\u73b0\u7684&#xff0c;\u56e0\u6b64\u4f60\u662f\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 \/etc\/systemd\/system\/multi-user.target \u914d\u7f6e\u6587\u4ef6\u6765\u505a\u5230\u8ba9\u6307\u5b9a\u670d\u52a1\u5f00\u673a\u81ea\u542f\u7684\u3002<\/p>\n<p>\u4f46\u6211\u4eec\u524d\u9762\u4e5f\u8bf4\u8fc7&#xff0c;\u7cfb\u7edf\u9884\u7f6e\u7684 Unit \u6587\u4ef6\u4e00\u822c\u4e0d\u8981\u968f\u4fbf\u6539\u52a8\u3002\u4e8e\u662f\u5b98\u65b9\u53c8\u4e3a\u5176\u8bbe\u8ba1\u4e86 \/etc\/systemd\/system\/multi-user.target.wants\/ \u76ee\u5f55&#xff0c;\u5176\u529f\u80fd\u4e0e Unit \u6587\u4ef6\u4e2d\u7684 Wants \u53c2\u6570\u7684\u4f5c\u7528\u662f\u4e00\u6837\u7684&#xff0c;\u4e0d\u7528\u968f\u4fbf\u4fee\u6539\u6587\u4ef6\u53ea\u9700\u628a\u6307\u5b9a\u670d\u52a1\u7684\u8f6f\u94fe\u63a5\u653e\u8fdb\u53bb\u5c31\u53ef\u4ee5&#xff0c;\u4e5f\u4e0d\u7528\u8001\u662f\u5728\u4fee\u6539\u5b8c Unit \u6587\u4ef6\u4e4b\u540e\u9700\u8981\u9891\u7e41\u6267\u884c systemctl daemon-reload \u52a0\u8f7d\u4fe1\u606f&#xff0c;\u53ef\u8c13\u662f\u76f8\u5f53\u7075\u6d3b\u3002<\/p>\n<p>\u6ce8&#xff1a;\u670d\u52a1\u5bf9\u5e94\u7684 Unit \u6587\u4ef6&#xff08;\u6b64\u5904\u4ee5 nginx.service \u4e3a\u4f8b&#xff09;\u4e2d [Install] \u5757\u4e0b\u7684 WantedBy &#061; multi-user.target \u662f\u6307&#xff0c;\u5f53\u6267\u884c systemctl enable nginx.service \u65f6&#xff0c;\u4fbf\u4f1a\u4e3a nginx.service \u521b\u5efa\u8f6f\u94fe\u63a5&#xff0c;\u94fe\u63a5\u76ee\u6807\u4fbf\u662f\u5728 multi-user.target \u7684 wants \u6587\u4ef6\u5939\u4e0b\u9762&#xff0c;\u5373 \/etc\/systemd\/system\/multi-user.target \u3002<\/p>\n<p>&#xff08;4&#xff09;Unit \u6a21\u677f\u5355\u5143\u793a\u4f8b&#xff08;\u6b64\u5904\u4ee5 vsftpd \u4e3a\u4f8b&#xff09;&#xff1a;<\/p>\n<p>\u4ee5\u524d&#xff0c;\u5982\u679c\u6211\u4eec\u60f3\u8fd0\u884c\u591a\u4e2a FTP \u5b9e\u4f8b&#xff0c;\u90a3\u6211\u4eec\u4f1a\u4e3a\u5176\u914d\u7f6e\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6&#xff08;\u5982 ftpd1.conf\u3001ftpd2.conf\u3001ftpd3.conf \u7b49&#xff09;&#xff0c;\u7136\u540e\u6309\u7167 vsftpd \/etc\/vsftpd\/ftpd1.conf\u3001vsftpd \/etc\/vsftpd\/ftpd2.conf\u3001vsftpd \/etc\/vsftpd\/ftpd3.conf \u7684\u65b9\u5f0f\u53bb\u4e00\u4e00\u542f\u52a8\u3002<\/p>\n<p>\u4f46\u73b0\u5728&#xff0c;\u6211\u4eec\u7ba1\u7406\u670d\u52a1\u90fd\u662f\u901a\u8fc7 systemd \u8fdb\u884c\u7684&#xff0c;\u90a3\u8be5\u5982\u4f55\u5b9e\u73b0\u901a\u8fc7 systemctl \u8fbe\u5230\u4e00\u952e\u5f00\u542f\u591a\u4e2a\u5b9e\u4f8b\u7684\u6548\u679c\u5462&#xff1f;\u8fd9\u5c31\u8f6e\u5230 Unit \u6a21\u677f\u5355\u5143\u6765\u5c55\u793a\u4e86\u3002<\/p>\n<p>\u7528\u6cd5\u5176\u5b9e\u4e5f\u5f88\u7b80\u5355&#xff0c;\u5c31\u662f\u5c06\u5e38\u89c4\u7684 vsftpd.service \u6587\u4ef6\u4e2d\u5173\u4e8e\u914d\u7f6e\u6587\u4ef6\u53d8\u52a8\u7684\u5730\u65b9\u6539\u6210\u53d8\u91cf\u7684\u5f62\u5f0f\u5c31\u597d\u4e86&#xff0c;\u5982\u4e0b&#xff1a;<\/p>\n<p># cat \/usr\/lib\/systemd\/system\/vsftpd&#064;.service<\/p>\n<p>[Unit]<br \/>\nDescription&#061;Vsftpd ftp daemon<br \/>\nAfter&#061;network.target<br \/>\nPartOf&#061;vsftpd.target<\/p>\n<p>[Service]<br \/>\nType&#061;forking<br \/>\nExecStart&#061;\/usr\/sbin\/vsftpd \/etc\/vsftpd\/ftpd%I.conf<\/p>\n<p>#[Install]<br \/>\n#WantedBy&#061;vsftpd.target<br \/>\n# \u6ce8\u610f&#xff1a;\u8be5\u914d\u7f6e\u6765\u81ea\u9e1f\u54e5\u79c1\u623f\u83dc\u3002\u6b64\u5904\u5e76\u975e\u662f multi-user.target&#xff0c;\u800c\u662f\u4e00\u4e2a\u81ea\u5efa\u7684 vsftpd.target&#xff0c;\u8fd9\u4e00\u70b9\u4f3c\u4e4e\u6709\u8bf4\u6cd5&#xff0c;\u4f46\u6211\u89c9\u5f97\u76f4\u63a5\u6ce8\u91ca\u5373\u53ef&#xff0c;\u4f5c\u7528\u4e0d\u5927\u3002<\/p>\n<p>\u5982\u6b64\u4e00\u6765&#xff0c;\u6211\u4eec\u60f3\u542f\u52a8 ftpd2.conf \u914d\u7f6e\u6587\u4ef6\u7684\u5b9e\u4f8b\u5c31\u6267\u884c systemctl start vsftpd&#064;2.service&#xff0c;\u60f3\u542f\u52a8 ftpd3.conf \u7684\u5b9e\u4f8b&#xff0c;\u5c31\u6267\u884c systemctl start vsftpd&#064;3.service \u3002\u53ef\u8fd9\u6837\u8fd8\u662f\u6709\u4e2a\u4e0d\u65b9\u4fbf\u7684\u5730\u65b9&#xff0c;\u90a3\u5c31\u662f\u5982\u679c\u6211\u4eec\u60f3\u5c06\u4e09\u4e2a\u5b9e\u4f8b\u90fd\u542f\u52a8\u8d77\u6765&#xff0c;\u5c31\u9700\u8981\u8fde\u7eed\u6267\u884c 3 \u6b21\u542f\u52a8\u547d\u4ee4&#xff0c;\u800c\u4e14\u8fd9\u79cd\u6a21\u677f\u670d\u52a1\u4f3c\u4e4e\u4e5f\u4e0d\u80fd\u591f\u8fdb\u884c\u5f00\u673a\u81ea\u542f\u3002<\/p>\n<p>\u6ce8&#xff1a;\u5728 systemctl start vsftpd&#064;1.service \u4e2d&#xff0c;&#064; \u540e\u9762\u7684\u5b57\u4e32\u4f1a\u88ab\u5f53\u505a\u53c2\u6570\u8d4b\u503c\u7ed9\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u53d8\u91cf %I\u3002<\/p>\n<p>\u8fd9\u65f6\u5019\u6211\u4eec\u5c31\u53ef\u4ee5\u7528\u5230 target \u8fd9\u4e2a Unit \u4e86&#xff0c;\u8ba9\u5b83\u6765\u5e2e\u6211\u4eec\u5b9e\u73b0\u4e00\u952e\u542f\u52a8\u591a\u4e2a\u6a21\u677f\u5b9e\u4f8b\u7684\u6548\u679c\u3002<\/p>\n<table>\n<tr>\u6211\u7684\u535a\u5ba2\u56ed<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u513f\u65f6\u7ec3\u529f\u6613&#xff0c;\u8001\u6765\u5b66\u827a\u96be\u3002 \u5bfc\u822a<br \/>\n0 \u524d\u8a001 \u5de5\u5177\u4ecb\u7ecd2 \u914d\u7f6e\u7ed3\u67843 Unit \u5b9e\u4f8b 3.0 \u901a\u7528\u5757 3.0.1 Unit \u5757\u53c2\u65703.0.2 Install \u5757\u53c2\u6570 3.1 Service3.2 Target3.3 Timer3.4 Path3.5 Slice3.5 Mount3.6 Automount 4 \u547d\u4ee4\u7ba1\u7406 4.1 systemctl \u547d\u4ee4\u7528\u6cd54.2 journalctl \u547d\u4ee4\u7528\u6cd5 5 \u6742\u4e03\u6742\u516b 0\u3001\u524d\u8a00 \u5f53\u6211\u4eec\u6253\u5f00 Linux \u4e3b\u673a\u4ee5\u547d\u4ee4\u884c\u6a21\u5f0f\u6216\u56fe\u5f62<\/p>\n","protected":false},"author":2,"featured_media":94299,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9098,58,44],"topic":[],"class_list":["post-94301","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-it","tag-linux","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Systemd \u5b66\u4e60\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/94301.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Systemd \u5b66\u4e60\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u513f\u65f6\u7ec3\u529f\u6613&#xff0c;\u8001\u6765\u5b66\u827a\u96be\u3002 \u5bfc\u822a 0 \u524d\u8a001 \u5de5\u5177\u4ecb\u7ecd2 \u914d\u7f6e\u7ed3\u67843 Unit \u5b9e\u4f8b 3.0 \u901a\u7528\u5757 3.0.1 Unit \u5757\u53c2\u65703.0.2 Install \u5757\u53c2\u6570 3.1 Service3.2 Target3.3 Timer3.4 Path3.5 Slice3.5 Mount3.6 Automount 4 \u547d\u4ee4\u7ba1\u7406 4.1 systemctl \u547d\u4ee4\u7528\u6cd54.2 journalctl \u547d\u4ee4\u7528\u6cd5 5 \u6742\u4e03\u6742\u516b 0\u3001\u524d\u8a00 \u5f53\u6211\u4eec\u6253\u5f00 Linux \u4e3b\u673a\u4ee5\u547d\u4ee4\u884c\u6a21\u5f0f\u6216\u56fe\u5f62\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/94301.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-14T00:49:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260814004859-6a7e65fbcd3f8.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/94301.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/94301.html\",\"name\":\"Systemd \u5b66\u4e60\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-14T00:49:01+00:00\",\"dateModified\":\"2026-08-14T00:49:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/94301.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/94301.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/94301.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Systemd \u5b66\u4e60\u603b\u7ed3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Systemd \u5b66\u4e60\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/94301.html","og_locale":"zh_CN","og_type":"article","og_title":"Systemd \u5b66\u4e60\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u513f\u65f6\u7ec3\u529f\u6613&#xff0c;\u8001\u6765\u5b66\u827a\u96be\u3002 \u5bfc\u822a 0 \u524d\u8a001 \u5de5\u5177\u4ecb\u7ecd2 \u914d\u7f6e\u7ed3\u67843 Unit \u5b9e\u4f8b 3.0 \u901a\u7528\u5757 3.0.1 Unit \u5757\u53c2\u65703.0.2 Install \u5757\u53c2\u6570 3.1 Service3.2 Target3.3 Timer3.4 Path3.5 Slice3.5 Mount3.6 Automount 4 \u547d\u4ee4\u7ba1\u7406 4.1 systemctl \u547d\u4ee4\u7528\u6cd54.2 journalctl \u547d\u4ee4\u7528\u6cd5 5 \u6742\u4e03\u6742\u516b 0\u3001\u524d\u8a00 \u5f53\u6211\u4eec\u6253\u5f00 Linux \u4e3b\u673a\u4ee5\u547d\u4ee4\u884c\u6a21\u5f0f\u6216\u56fe\u5f62","og_url":"https:\/\/www.wsisp.com\/helps\/94301.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-14T00:49:01+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260814004859-6a7e65fbcd3f8.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/94301.html","url":"https:\/\/www.wsisp.com\/helps\/94301.html","name":"Systemd \u5b66\u4e60\u603b\u7ed3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-14T00:49:01+00:00","dateModified":"2026-08-14T00:49:01+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/94301.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/94301.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/94301.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Systemd \u5b66\u4e60\u603b\u7ed3"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/94301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=94301"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/94301\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/94299"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=94301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=94301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=94301"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=94301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}