{"id":15190,"date":"2023-09-19T06:09:19","date_gmt":"2023-09-18T21:09:19","guid":{"rendered":"https:\/\/lab4ict.com\/system\/?p=15190"},"modified":"2023-09-19T07:02:07","modified_gmt":"2023-09-18T22:02:07","slug":"linux%e3%81%a7systemd%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%a6%e3%82%b7%e3%82%a7%e3%83%ab%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b%ef%bc%81","status":"publish","type":"post","link":"https:\/\/lab4ict.com\/system\/archives\/15190","title":{"rendered":"Linux\u3067Systemd\u3092\u4f7f\u7528\u3057\u3066\u30b7\u30a7\u30eb\uff08\u30b3\u30de\u30f3\u30c9\uff09\u3092\u5b9f\u884c\u3059\u308b\uff01"},"content":{"rendered":"<p>Linux\u3067Systemd\u3092\u4f7f\u7528\u3057\u3066\u30b7\u30a7\u30eb\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<br \/>\n<!--more--><\/p>\n<h2>Systemd\u304b\u3089\u5b9f\u884c\u3059\u308b\u30b7\u30a7\u30eb\u3092\u4f5c\u6210\u3059\u308b\uff01<\/h2>\n<p>Systemd\u304b\u3089\u5b9f\u884c\u3059\u308b\u30b7\u30a7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u3001\u4f8b\u3068\u3057\u3066\u4e00\u822c\u30e6\u30fc\u30b6\u3067date\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u30b7\u30a7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ cat \/home\/usradmin\/bin\/date.sh \r\n#!\/bin\/bash\r\n\r\ndate &gt; \/home\/usradmin\/data\/date.txt\r\n<\/pre>\n<h2>Unit\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3059\u308b\uff01<\/h2>\n<p>\u30e6\u30fc\u30b6\u6a29\u9650\u3067Unit\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306eUnit\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ mkdir -p ~\/.config\/systemd\/user\r\n<\/pre>\n<h2>Unit\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\uff01<\/h2>\n<p>Unit\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ cat \/home\/usradmin\/.config\/systemd\/user\/date.service\r\n&#x5B;Unit]\r\nDescription=Service date.sh\r\n\r\n&#x5B;Service]\r\nType=oneshot\r\nExecStart=\/home\/usradmin\/bin\/date.sh\r\n\r\n&#x5B;Install]\r\nWantedBy=default.target\r\n<\/pre>\n<h2>Unit\u30d5\u30a1\u30a4\u30eb\u304cSystemd\u306b\u8a8d\u8b58\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\uff01<\/h2>\n<p>Unit\u30d5\u30a1\u30a4\u30eb\u304cSystemd\u306b\u8a8d\u8b58\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u300c--user\u300d\u3092\u4f7f\u7528\u3059\u308b\u3068\u3053\u308d\u304c\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ systemctl --user status date.service\r\n\u25cb date.service - Service date.sh\r\n     Loaded: loaded (\/home\/usradmin\/.config\/systemd\/user\/date.service; disabled; preset: disabled)\r\n     Active: inactive (dead)\r\n<\/pre>\n<h2>Systemd\u3092\u4f7f\u7528\u3057\u3066Unit\u3092\u5b9f\u884c\u3059\u308b\uff01<\/h2>\n<p>\u4f5c\u6210\u3057\u305fUnit\u3092Systemd\u3092\u4f7f\u7528\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2]; title: ; notranslate\" title=\"\">\r\n$ systemctl --user start date.service\r\n$ systemctl --user status date.service\r\n\u25cb date.service - Date Service\r\n     Loaded: loaded (\/home\/usradmin\/.config\/systemd\/user\/date.service; disabled; preset: disabled)\r\n     Active: inactive (dead)\r\n\r\nSep 19 06:17:54 vmsrhe21.loc.lab4ict.com systemd&#x5B;2144]: Starting Date Service...\r\nSep 19 06:17:54 vmsrhe21.loc.lab4ict.com systemd&#x5B;2144]: Finished Date Service.\r\n<\/pre>\n<p>\u5b9f\u884c\u6642\u9593\u304c\u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u9332\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ cat ~\/data\/date.txt \r\nTue Sep 19 06:17:54 AM JST 2023\r\n<\/pre>\n<h2>Unit\u3092\u30bf\u30a4\u30de\u30fc\u8d77\u52d5\u3059\u308b\uff01<\/h2>\n<p>\u4f5c\u6210\u3057\u305fUnit\u30921\u5206\u304a\u304d\u306b\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002\u30bf\u30a4\u30de\u30fc\u7528\u306eUnit\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30bf\u30a4\u30de\u30fc\u7528\u306eUnit\u306f\u3001\u5b9f\u884c\u7528\u306eUnit\u30d5\u30a1\u30a4\u30eb\u3068\u540d\u524d\u3092\u5408\u308f\u305b\u307e\u3059\u3002\u4eca\u56de\u306f\u3001\u300cdate.timer\u300d\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ cat ~\/.config\/systemd\/user\/date.timer\r\n&#x5B;Unit]\r\nDescription=timer date.sh\r\n\r\n&#x5B;Timer]\r\nOnCalendar=*:0\/1\r\n<\/pre>\n<h2>\u4f5c\u6210\u3057\u305f\u30bf\u30a4\u30de\u30fc\u3092\u8d77\u52d5\u3059\u308b\uff01<\/h2>\n<p>\u4f5c\u6210\u3057\u305f\u30bf\u30a4\u30de\u30fc\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,2]; title: ; notranslate\" title=\"\">\r\n$ systemctl --user start date.timer \r\n$ systemctl --user status date.timer \r\n\u25cf date.timer - timer date.sh\r\n     Loaded: loaded (\/home\/usradmin\/.config\/systemd\/user\/date.timer; static)\r\n     Active: active (waiting) since Tue 2023-09-19 06:51:00 JST; 3s ago\r\n      Until: Tue 2023-09-19 06:51:00 JST; 3s ago\r\n    Trigger: Tue 2023-09-19 06:52:00 JST; 55s left\r\n   Triggers: \u25cf date.service\r\n\r\nSep 19 06:51:00 vmsrhe21.loc.lab4ict.com systemd&#x5B;2144]: Started timer date.sh.\r\n<\/pre>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>Systemd\u3092\u4f7f\u7528\u3057\u3066\u3001\u30e6\u30fc\u30b6\u6a29\u9650\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u3092\u78ba\u8a8d\u3057\u307e\u3057\u305f\u3002\u3082\u3061\u308d\u3093\u3001\u30b3\u30de\u30f3\u30c9\u306e\u307f\u306e\u5b9f\u884c\u3082\u53ef\u80fd\u3067\u3059\u3002\u30bf\u30a4\u30de\u30fc\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u3082\u78ba\u8a8d\u3057\u307e\u3057\u305f\u3002<\/p>\n<h2>\u53c2\u8003\u60c5\u5831<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/systemd.time.html#\" rel=\"noopener\" target=\"_blank\">Systemd - Timer<\/a><\/li>\n<\/ul>\n<h2>\u95a2\u9023\u8a18\u4e8b<\/h2>\n<div class=\"sc_getpost\"><a class=\"clearfix\" href=\"https:\/\/lab4ict.com\/system\/archives\/9684\" ><div class=\"sc_getpost_thumb post-box-thumbnail__wrap\"><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODdhAQABAPAAAN3d3QAAACwAAAAAAQABAAACAkQBADs=\" width=\"150\" height=\"150\" alt=\"\u3010\u8a18\u4e8b\u4e00\u89a7\u3011Linux\u3067\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u3092\u4f7f\u7528\u3059\u308b\uff01\" loading=\"lazy\" data-src=\"https:\/\/lab4ict.com\/system\/wp-content\/uploads\/2021\/02\/fi_linux_01-150x150.png\" class=\"lazyload\"><\/div><div class=\"title\">\u3010\u8a18\u4e8b\u4e00\u89a7\u3011Linux\u3067\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u3092\u4f7f\u7528\u3059\u308b\uff01<\/div><div class=\"substr\">Linux\u3067\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u8a18\u4e8b\u4e00\u89a7\u3092\u63b2\u8f09\u3057\u307e\u3059\u3002...<\/div><\/a><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u3067Systemd\u3092\u4f7f\u7528\u3057\u3066\u30b7\u30a7\u30eb\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":5527,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[206],"tags":[282,283,25,935,1211,666],"class_list":["post-15190","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scheduler","tag-linux","tag-systemd","tag-25","tag-935","tag-1211","tag-666"],"_links":{"self":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/15190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/comments?post=15190"}],"version-history":[{"count":17,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/15190\/revisions"}],"predecessor-version":[{"id":15208,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/15190\/revisions\/15208"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media\/5527"}],"wp:attachment":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media?parent=15190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/categories?post=15190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/tags?post=15190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}