{"id":463,"date":"2026-07-03T03:24:45","date_gmt":"2026-07-02T18:24:45","guid":{"rendered":"https:\/\/www.marchboy.xyz\/wordpress\/archives\/463"},"modified":"2026-07-03T03:25:44","modified_gmt":"2026-07-02T18:25:44","slug":"systemd%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9","status":"publish","type":"post","link":"https:\/\/www.marchboy.xyz\/wordpress\/archives\/463","title":{"rendered":"systemd\u30b5\u30fc\u30d3\u30b9\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p>Linux \u306e\u8d77\u52d5\u30fb\u505c\u6b62\u3084\u30d7\u30ed\u30bb\u30b9\u7ba1\u7406\u3092\u884c\u3046 <strong>systemd<\/strong> \u306f\u3001\u73fe\u5728\u306e\u307b\u3068\u3093\u3069\u306e\u30c7\u30a3\u30b9\u30c8\u30ea\u30d3\u30e5\u30fc\u30b7\u30e7\u30f3\u3067\u6a19\u6e96\u7684\u306b\u63a1\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u672c\u8a18\u4e8b\u3067\u306f\u3001systemd \u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u304b\u3089\u5b9f\u969b\u306b\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u6210\u30fb\u7ba1\u7406\u3059\u308b\u624b\u9806\u307e\u3067\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h2>systemd \u306e\u57fa\u672c\u69cb\u6210<\/h2>\n<p>systemd \u306f <strong>\u30e6\u30cb\u30c3\u30c8 (unit)<\/strong> \u3068\u547c\u3070\u308c\u308b\u69cb\u6210\u8981\u7d20\u3067\u69cb\u6210\u3055\u308c\u307e\u3059\u3002\u30e6\u30cb\u30c3\u30c8\u306f\u6a5f\u80fd\u3054\u3068\u306b\u7a2e\u985e\u304c\u5206\u304b\u308c\u3001\u30b5\u30fc\u30d3\u30b9 (service) \u30e6\u30cb\u30c3\u30c8\u304c\u6700\u3082\u4e00\u822c\u7684\u3067\u3059\u3002<\/p>\n<h2>\u57fa\u672c\u7684\u306a\u30b3\u30de\u30f3\u30c9<\/h2>\n<ul>\n<li><strong>systemctl status <em>\u30b5\u30fc\u30d3\u30b9\u540d<\/em><\/strong> \u2013 \u30b5\u30fc\u30d3\u30b9\u306e\u72b6\u614b\u3092\u78ba\u8a8d<\/li>\n<li><strong>systemctl start <em>\u30b5\u30fc\u30d3\u30b9\u540d<\/em><\/strong> \u2013 \u30b5\u30fc\u30d3\u30b9\u3092\u8d77\u52d5<\/li>\n<li><strong>systemctl stop <em>\u30b5\u30fc\u30d3\u30b9\u540d<\/em><\/strong> \u2013 \u30b5\u30fc\u30d3\u30b9\u3092\u505c\u6b62<\/li>\n<li><strong>systemctl restart <em>\u30b5\u30fc\u30d3\u30b9\u540d<\/em><\/strong> \u2013 \u30b5\u30fc\u30d3\u30b9\u3092\u518d\u8d77\u52d5<\/li>\n<li><strong>systemctl enable <em>\u30b5\u30fc\u30d3\u30b9\u540d<\/em><\/strong> \u2013 \u8d77\u52d5\u6642\u306b\u81ea\u52d5\u5b9f\u884c\u8a2d\u5b9a<\/li>\n<li><strong>systemctl disable <em>\u30b5\u30fc\u30d3\u30b9\u540d<\/em><\/strong> \u2013 \u8d77\u52d5\u6642\u81ea\u52d5\u5b9f\u884c\u3092\u89e3\u9664<\/li>\n<\/ul>\n<h2>\u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210<\/h2>\n<p>\u65b0\u3057\u3044\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u3001<code>\/etc\/systemd\/system\/<\/code> \u914d\u4e0b\u306b\u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb (\u62e1\u5f35\u5b50 .service) \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u6700\u5c0f\u69cb\u6210\u306e\u4f8b\u3067\u3059\u3002<\/p>\n<pre><code>[Unit]\nDescription=\u30b5\u30f3\u30d7\u30eb\u30b5\u30fc\u30d3\u30b9\nAfter=network.target\n\n[Service]\nType=simple\nExecStart=\/usr\/bin\/python3 \/opt\/sample\/app.py\nRestart=on-failure\n\n[Install]\nWantedBy=multi-user.target\n<\/code><\/pre>\n<p>\u30dd\u30a4\u30f3\u30c8:<\/p>\n<ul>\n<li><strong>[Unit]<\/strong> \u30bb\u30af\u30b7\u30e7\u30f3\u3067\u4f9d\u5b58\u95a2\u4fc2\u3084\u8aac\u660e\u3092\u8a18\u8ff0<\/li>\n<li><strong>[Service]<\/strong> \u3067\u5b9f\u884c\u30b3\u30de\u30f3\u30c9\u3084\u518d\u8d77\u52d5\u30dd\u30ea\u30b7\u30fc\u3092\u5b9a\u7fa9<\/li>\n<li><strong>[Install]<\/strong> \u3067\u6709\u52b9\u5316\u6642\u306e\u30bf\u30fc\u30b2\u30c3\u30c8\u3092\u6307\u5b9a<\/li>\n<\/ul>\n<h2>\u30b5\u30fc\u30d3\u30b9\u306e\u6709\u52b9\u5316\u3068\u8d77\u52d5<\/h2>\n<p>\u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u305f\u3089\u3001systemd \u306b\u518d\u8aad\u307f\u8fbc\u307f\u3055\u305b\u3001\u30b5\u30fc\u30d3\u30b9\u3092\u6709\u52b9\u5316\u30fb\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre><code># systemctl daemon-reload      # \u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u518d\u8aad\u307f\u8fbc\u307f\n# systemctl enable sample.service   # \u8d77\u52d5\u6642\u306b\u81ea\u52d5\u8d77\u52d5\u8a2d\u5b9a\n# systemctl start sample.service    # \u4eca\u3059\u3050\u8d77\u52d5\n# systemctl status sample.service   # \u72b6\u614b\u78ba\u8a8d\n<\/code><\/pre>\n<h2>\u30ed\u30b0\u306e\u78ba\u8a8d<\/h2>\n<p>systemd \u306f <strong>journald<\/strong> \u3068\u9023\u643a\u3057\u3001\u30b5\u30fc\u30d3\u30b9\u306e\u6a19\u6e96\u51fa\u529b\u30fb\u6a19\u6e96\u30a8\u30e9\u30fc\u3092\u30ed\u30b0\u3068\u3057\u3066\u53ce\u96c6\u3057\u307e\u3059\u3002\u30ed\u30b0\u306f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code># journalctl -u sample.service --since \"1 hour ago\"\n<\/code><\/pre>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>systemd \u306f\u5f37\u529b\u304b\u3064\u67d4\u8edf\u306a\u30b5\u30fc\u30d3\u30b9\u7ba1\u7406\u30c4\u30fc\u30eb\u3067\u3059\u3002\u4eca\u56de\u7d39\u4ecb\u3057\u305f\u624b\u9806\u3092\u8e0f\u3081\u3070\u3001\u72ec\u81ea\u306e\u30b5\u30fc\u30d3\u30b9\u3092\u7c21\u5358\u306b\u4f5c\u6210\u3057\u3001\u8d77\u52d5\u30fb\u505c\u6b62\u30fb\u81ea\u52d5\u8d77\u52d5\u8a2d\u5b9a\u30fb\u30ed\u30b0\u78ba\u8a8d\u307e\u3067\u4e00\u5143\u7ba1\u7406\u3067\u304d\u307e\u3059\u3002\u5b9f\u969b\u306e\u904b\u7528\u3067\u306f <strong>\u4f9d\u5b58\u95a2\u4fc2<\/strong> \u3084 <strong>\u30ea\u30bd\u30fc\u30b9\u5236\u9650<\/strong> \u306a\u3069\u9ad8\u5ea6\u306a\u8a2d\u5b9a\u3082\u4f75\u305b\u3066\u691c\u8a0e\u3059\u308b\u3068\u3001\u3088\u308a\u5b89\u5b9a\u3057\u305f\u30b7\u30b9\u30c6\u30e0\u904b\u7528\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b Linux \u306e\u8d77\u52d5\u30fb\u505c\u6b62\u3084\u30d7\u30ed\u30bb\u30b9\u7ba1\u7406\u3092\u884c\u3046 systemd \u306f\u3001\u73fe\u5728\u306e\u307b\u3068\u3093\u3069\u306e\u30c7\u30a3\u30b9\u30c8\u30ea\u30d3\u30e5\u30fc\u30b7\u30e7\u30f3\u3067\u6a19\u6e96\u7684\u306b\u63a1\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u672c\u8a18\u4e8b\u3067\u306f\u3001systemd \u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u304b\u3089\u5b9f\u969b\u306b\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u6210\u30fb\u7ba1\u7406\u3059\u308b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-463","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/comments?post=463"}],"version-history":[{"count":1,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/463\/revisions"}],"predecessor-version":[{"id":464,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/463\/revisions\/464"}],"wp:attachment":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/media?parent=463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/categories?post=463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/tags?post=463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}