{"id":7443,"date":"2018-03-08T15:31:33","date_gmt":"2018-03-08T15:31:33","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=7443"},"modified":"2018-04-09T18:27:42","modified_gmt":"2018-04-09T18:27:42","slug":"raspberry-pi-3-services","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=7443","title":{"rendered":"Raspberry Pi 3, Services"},"content":{"rendered":"<p><a href=\"https:\/\/www.raspberrypi.org\/documentation\/linux\/usage\/systemd.md\">systemd<\/a><br \/>\n<a href=\"https:\/\/fedoramagazine.org\/what-is-an-init-system\/\">What is an init system?<\/a><br \/>\n<a href=\"https:\/\/learn.adafruit.com\/running-programs-automatically-on-your-tiny-computer\/systemd-writing-and-enabling-a-service\">Running Programs Automatically on Your Tiny Computer: systemd: Writing and Enabling a Service<\/a><br \/>\n<a href=\"http:\/\/www.lions-wing.net\/maker\/raspberry-1\/boot.html\">Raspberry Pi Boot Process<\/a><br \/>\n<a href=\"https:\/\/raspberrypi.stackexchange.com\/questions\/78095\/clarification-about-the-boot-process-systemd-init\">Clarification about the boot process (systemd \/ init)<\/a><br \/>\n<a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-use-systemctl-to-manage-systemd-services-and-units\">How To Use Systemctl to Manage Systemd Services and Units<\/a><br \/>\n<a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-2-reference\">How To Configure a Linux Service to Start Automatically After a Crash or Reboot \u2013 Part 2: Reference<\/a><br \/>\n<a href=\"https:\/\/unix.stackexchange.com\/questions\/233468\/how-does-systemd-use-etc-init-d-scripts\">How does systemd use \/etc\/init.d scripts?<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nBefore: SysVinit (System V init, or just init)\r\nNow:    systemd\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n- In systemd, there is no concept of runlevels.\r\n- These are replaced by targets.\r\n- Targets can and do depend on each other.\r\n  basic.target =&gt; multi-user.target =&gt; graphical.target\r\n- Under SysVinit, scripts run strictly in order\r\n\r\nrunlevel                                             =&gt; systemd target\r\n0: halt\r\n1: single-user\r\n2: multi-user\r\n3: multi-user with networking                        =&gt; multi-user.target\r\n4: undefined (user defined)\r\n5: multi-user with display manager (graphical login) =&gt; graphical.target\r\n6: reboot\r\n\r\nbasic.target\r\nnetwork.target\r\nmulti-user.target\r\ngraphical.target\r\n\r\ninit.scope\r\nsystem.slice\r\n-.mount\r\n-.slice\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ sudo apt-get update\r\n$ sudo apt-get dist-upgrade\r\n$ sudo apt-get install graphviz\r\n$ sudo apt-get install tree\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ systemd-analyze critical-chain\r\nThe time after the unit is active or started is printed after the &quot;@&quot; character.\r\nThe time the unit takes to start is printed after the &quot;+&quot; character.\r\n\r\ngraphical.target @33.104s\r\n\u2514\u2500multi-user.target @33.103s\r\n  \u2514\u2500getty.target @33.103s\r\n    \u2514\u2500getty@tty1.service @33.102s\r\n      \u2514\u2500systemd-user-sessions.service @33.030s +16ms\r\n        \u2514\u2500network.target @33.023s\r\n          \u2514\u2500dhcpcd.service @2.326s +30.692s\r\n            \u2514\u2500basic.target @2.161s\r\n              \u2514\u2500sockets.target @2.161s\r\n                \u2514\u2500triggerhappy.socket @2.160s\r\n                  \u2514\u2500sysinit.target @2.155s\r\n                    \u2514\u2500systemd-timesyncd.service @1.930s +224ms\r\n                      \u2514\u2500systemd-tmpfiles-setup.service @1.864s +55ms\r\n                        \u2514\u2500local-fs.target @1.854s\r\n                          \u2514\u2500boot.mount @1.836s +16ms\r\n                            \u2514\u2500systemd-fsck@dev-disk-by\\x2dpartuuid-fc38305d\\x2d01.service @1.492s +336ms\r\n                              \u2514\u2500dev-disk-by\\x2dpartuuid-fc38305d\\x2d01.device @1.489s\r\n\r\n$ systemd-analyze dot | dot -Tsvg &gt; systemd.svg\r\n   Color legend: black     = Requires\r\n                 dark blue = Requisite\r\n                 dark grey = Wants\r\n                 red       = Conflicts\r\n                 green     = After\r\n\r\n$ pstree\r\nsystemd-+-agetty\r\n        |-avahi-daemon---avahi-daemon\r\n        |-bluetoothd\r\n        |-cron\r\n        |-dbus-daemon\r\n        |-dhcpcd\r\n        |-hciattach\r\n        |-login---bash\r\n        |-rsyslogd-+-{in:imklog}\r\n        |          |-{in:imuxsock}\r\n        |          `-{rs:main Q:Reg}\r\n        |-sshd---sshd---sshd---bash---pstree\r\n        |-systemd---(sd-pam)\r\n        |-systemd-journal\r\n        |-systemd-logind\r\n        |-systemd-timesyn---{sd-resolve}\r\n        |-systemd-udevd\r\n        |-thd\r\n        `-wpa_supplicant\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nGlobal:\r\n\/etc\/systemd\/system\r\n\/lib\/systemd\/system\/\r\n\r\nUser:\r\n\/etc\/systemd\/user,\r\n\/run\/systemd\/user\r\n\/lib\/systemd\/user\r\n\/usr\/lib\/systemd\/user\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ systemctl status\r\n\r\n$ systemctl\r\nor \r\n$ systemctl list-units\r\n\r\n$ systemctl list-unit-files\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nService units\r\nTarget units\r\n\r\nunit\r\nslice\r\nscope\r\nservice\r\n\r\nservices (.service)\r\nmount points (.mount)\r\ndevices (.device)\r\nsockets (.socket)\r\n(.automount)\r\n(.swap)\r\n(.target)\r\n(.path)\r\n(.timer)\r\n(.slice)\r\n(.scope) \r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ sudo systemctl start myscript.service\r\n$ sudo systemctl stop myscript.service\r\n$ sudo systemctl enable myscript.service\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nautologin@.service\r\nbluetooth.target.wants\r\ndbus-org.bluez.service -&gt; \/lib\/systemd\/system\/bluetooth.service\r\ndbus-org.freedesktop.Avahi.service -&gt; \/lib\/systemd\/system\/avahi-daemon.service\r\ndhcpcd.service.d\r\ndhcpcd5.service -&gt; \/lib\/systemd\/system\/dhcpcd.service\r\ngetty.target.wants\r\ngetty@tty1.service.d\r\nhalt.target.wants\r\nmulti-user.target.wants\r\nnetwork-online.target.wants\r\npoweroff.target.wants\r\nrc-local.service.d\r\nreboot.target.wants\r\nremote-fs.target.wants\r\nsockets.target.wants\r\nsshd.service -&gt; \/lib\/systemd\/system\/ssh.service\r\nsysinit.target.wants\r\nsyslog.service -&gt; \/lib\/systemd\/system\/rsyslog.service\r\ntimers.target.wants\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>systemd What is an init system? Running Programs Automatically on Your Tiny Computer: systemd: Writing and Enabling a Service Raspberry Pi Boot Process Clarification about the boot process (systemd \/ init) How To Use Systemctl to Manage Systemd Services and Units How To Configure a Linux Service to Start Automatically After a Crash or Reboot [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7443","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/7443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7443"}],"version-history":[{"count":24,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/7443\/revisions"}],"predecessor-version":[{"id":7642,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/7443\/revisions\/7642"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}