自定义服务(systemd)不会在启动时运行

自定义服务(systemd)不会在启动时运行

我正在 Raspbian 中创建一个非交互式信息亭。我把我不想要的所有东西都删掉了——桌面管理器、各种图形服务等——脚本以 X 开头,一个绝对最小的桌面管理器和 Chromium,加上十几行对抗各种屏幕消隐功能的行,以及另外十几行或更多阻止 Chromium 的行。来自各种弹出窗口的垃圾邮件。

我也为 systemd 创建了单元文件。

从命令行启动时它工作正常。从 开始它工作得很好systemctl start chromium.service。但在我的一生中,我无法让它在启动时自动启动。

首先,单元文件/etc/systemd/system/chromium.service

[Unit]
Description=Start X and Chromium in kiosk mode
After=getty.target

[Service]
Type=idle
User=pi
ExecStart=/home/pi/start-chromium

[Install]
WantedBy=graphical.target

图形目标是默认的:

 root@raspberrypi:/home/pi# ls -l /etc/systemd/system/default.target
 lrwxrwxrwx 1 root root 36 lut 24 17:00 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target

已经激活了:

  root@raspberrypi:/home/pi# ls -l /etc/systemd/system/graphical.target.wants/
  lrwxrwxrwx 1 root root 36 lut 24 16:28 chromium.service -> /etc/systemd/system/chromium.service

启动消息显示已达到图形目标;自定义服务应介于 getty 和graphical.target 之间:

[  OK  ] Started Terminate Plymouth Boot Screen.
         Starting Getty on tty1...
[  OK  ] Started Getty on tty1.
         Starting Serial Getty on ttyAMA0...
[  OK  ] Started Serial Getty on ttyAMA0.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started LSB: Start NTP daemon.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.
         Starting Update UTMP about System Runlevel Changes...
[  OK  ] Started Update UTMP about System Runlevel Changes.

但自定义服务不会出现在日志中的任何位置。

-- The start-up result is done.
lut 24 14:06:03 raspberrypi systemd[1]: Starting Getty on tty1...
-- Subject: Unit [email protected] has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit [email protected] has begun starting up.
lut 24 14:06:03 raspberrypi systemd[1]: Started Getty on tty1.
-- Subject: Unit [email protected] has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit [email protected] has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:03 raspberrypi systemd[1]: Starting Serial Getty on ttyAMA0...
-- Subject: Unit [email protected] has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit [email protected] has begun starting up.
lut 24 14:06:03 raspberrypi systemd[1]: Started Serial Getty on ttyAMA0.
-- Subject: Unit [email protected] has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit [email protected] has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:03 raspberrypi systemd[1]: Starting Login Prompts.
-- Subject: Unit getty.target has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit getty.target has begun starting up.
lut 24 14:06:03 raspberrypi systemd[1]: Reached target Login Prompts.
-- Subject: Unit getty.target has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit getty.target has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:03 raspberrypi ntpd[492]: ntpd [email protected] Mon Nov  2 04:29:47 UTC 2015 (1)
lut 24 14:06:03 raspberrypi ntpd[499]: proto: precision = 0.833 usec
lut 24 14:06:03 raspberrypi ntp[464]: Starting NTP server: ntpd.
lut 24 14:06:03 raspberrypi systemd[1]: Started LSB: Start NTP daemon.
-- Subject: Unit ntp.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit ntp.service has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:03 raspberrypi systemd[1]: Starting Multi-User System.
-- Subject: Unit multi-user.target has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit multi-user.target has begun starting up.
lut 24 14:06:03 raspberrypi systemd[1]: Reached target Multi-User System.
-- Subject: Unit multi-user.target has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit multi-user.target has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:03 raspberrypi systemd[1]: Starting Graphical Interface.
-- Subject: Unit graphical.target has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit graphical.target has begun starting up.
lut 24 14:06:03 raspberrypi systemd[1]: Reached target Graphical Interface.
-- Subject: Unit graphical.target has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

编辑:

root@raspberrypi:/home/pi# journalctl -u chromium
-- Logs begin at śro 2016-02-24 14:05:59 UTC, end at czw 2016-02-25 09:11:23 UTC. --

root@raspberrypi:/home/pi# systemctl status chromium
● chromium.service - Start X and Chromium in kiosk mode
   Loaded: loaded (/etc/systemd/system/chromium.service; enabled)
   Active: inactive (dead)

(无论我让脚本完成将其所有进程发送到后台,还是在最后等待(&从最后一个命令中删除chromium-browser),这都不会改变。

我缺少什么?

编辑 2:日志级别为 Loglevel=debug。13:32:45 附近有一些关于 Chromium 的条目,但它们并没有向我透露任何信息。

lut 24 14:06:15 raspberrypi systemd[520]: pam_unix(systemd-user:session): session opened for user pi by (uid=0)
lut 24 14:06:15 raspberrypi systemd[520]: Executing: /lib/systemd/systemd --user
lut 24 14:06:15 raspberrypi systemd[520]: Starting Paths.
-- Subject: Unit UNIT has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has begun starting up.
lut 24 14:06:15 raspberrypi systemd[520]: Reached target Paths.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:15 raspberrypi systemd[520]: Starting Timers.
-- Subject: Unit UNIT has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has begun starting up.
lut 24 14:06:15 raspberrypi systemd[520]: Reached target Timers.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:15 raspberrypi systemd[520]: Starting Sockets.
-- Subject: Unit UNIT has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has begun starting up.
lut 24 14:06:15 raspberrypi systemd[520]: Reached target Sockets.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:15 raspberrypi systemd[520]: Starting Basic System.
-- Subject: Unit UNIT has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has begun starting up.
lut 24 14:06:15 raspberrypi systemd[520]: Reached target Basic System.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:15 raspberrypi systemd[520]: Starting Default.
-- Subject: Unit UNIT has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has begun starting up.
lut 24 14:06:15 raspberrypi systemd[520]: Reached target Default.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:15 raspberrypi systemd[520]: Startup finished in 66ms.
-- Subject: System start-up is now complete
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- All system services necessary queued for starting at boot have been
-- successfully started. Note that this does not mean that the machine is
-- now idle as services might still be busy with completing start-up.
--
-- Kernel start-up required KERNEL_USEC microseconds.
--
-- Initial RAM disk start-up required INITRD_USEC microseconds.
--
-- Userspace start-up required 66978 microseconds.
lut 24 14:06:15 raspberrypi systemd[1]: Got notification message for unit [email protected]
lut 24 14:06:15 raspberrypi systemd[1]: [email protected]: Got notification message from PID 520 (READY=1...)
lut 24 14:06:15 raspberrypi systemd[1]: [email protected]: got READY=1
lut 24 14:06:15 raspberrypi systemd[1]: [email protected] changed start -> running
lut 24 14:06:15 raspberrypi systemd[1]: Job [email protected]/start finished, result=done
lut 24 14:06:15 raspberrypi systemd[1]: Started User Manager for UID 1000.
-- Subject: Unit [email protected] has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit [email protected] has finished starting up.
--
-- The start-up result is done.
lut 24 14:06:15 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobRemoved cookie=109 reply_cookie=0 error=n/a
lut 24 14:06:15 raspberrypi systemd[1]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RemoveMatch cookie=110 reply_cookie=0 error=n/a
lut 24 14:06:15 raspberrypi systemd[1]: [email protected]: got STATUS=Startup finished in 66ms.
lut 24 14:06:15 raspberrypi systemd[1]: Got notification message for unit [email protected]
lut 24 14:06:15 raspberrypi systemd[1]: [email protected]: got STATUS=Startup finished in 66ms.
lut 24 14:06:15 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1/unit/user_401000_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=111 reply_cookie=0 error=n/a
lut 24 14:06:15 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1/unit/user_401000_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=112 reply_cookie=0 error=n/a
lut 24 14:06:15 raspberrypi systemd[1]: [email protected]: Got notification message from PID 520 (READY=1...)
lut 24 14:06:16 raspberrypi dhcpcd[415]: eth0: carrier acquired
lut 24 14:06:16 raspberrypi kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
lut 24 14:06:16 raspberrypi kernel: smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
lut 24 14:06:16 raspberrypi dhcpcd[415]: DUID 00:01:00:01:1e:4c:e0:00:b8:27:eb:8e:4a:e3
lut 24 14:06:16 raspberrypi dhcpcd[415]: eth0: IAID eb:8e:4a:e3
lut 24 14:06:16 raspberrypi ntpd_intres[512]: host name not found: 0.debian.pool.ntp.org
lut 24 14:06:16 raspberrypi ntpd_intres[512]: host name not found: 1.debian.pool.ntp.org
lut 24 14:06:16 raspberrypi ntpd_intres[512]: host name not found: 2.debian.pool.ntp.org
lut 24 14:06:16 raspberrypi ntpd_intres[512]: host name not found: 3.debian.pool.ntp.org
lut 24 14:06:16 raspberrypi dhcpcd[415]: eth0: using static address 192.168.0.79/24
lut 24 14:06:16 raspberrypi dhcpcd[415]: eth0: adding route to 192.168.0.0/24
lut 24 14:06:16 raspberrypi dhcpcd[415]: eth0: adding default route via 192.168.0.222
lut 24 14:06:16 raspberrypi avahi-daemon[400]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.0.79.
lut 24 14:06:16 raspberrypi avahi-daemon[400]: New relevant interface eth0.IPv4 for mDNS.
lut 24 14:06:16 raspberrypi avahi-daemon[400]: Registering new address record for 192.168.0.79 on eth0.IPv4.
lut 24 14:06:16 raspberrypi systemd[1]: Accepted new private connection.
lut 24 14:06:16 raspberrypi systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 object=/org/freedesktop/systemd1/unit/nscd_2eservice interface=org.freedesktop.DBus.Properties member=GetAll cookie=1 reply_cookie=0 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Failed to load configuration for nscd.service: No such file or directory
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=method_return sender=n/a destination=n/a object=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Collecting nscd.service
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitNew cookie=2 reply_cookie=0 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitNew cookie=113 reply_cookie=0 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitRemoved cookie=3 reply_cookie=0 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitRemoved cookie=114 reply_cookie=0 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Got disconnect on private connection.
lut 24 14:06:16 raspberrypi systemd[1]: Accepted new private connection.
lut 24 14:06:16 raspberrypi systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 object=/org/freedesktop/systemd1/unit/unbound_2eservice interface=org.freedesktop.DBus.Properties member=GetAll cookie=1 reply_cookie=0 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Failed to load configuration for unbound.service: No such file or directory
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=method_return sender=n/a destination=n/a object=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Collecting unbound.service
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitNew cookie=2 reply_cookie=0 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitNew cookie=115 reply_cookie=0 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitRemoved cookie=3 reply_cookie=0 error=n/a
lut 24 14:06:16 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitRemoved cookie=116 reply_cookie=0 error=n/a
lut 24 14:06:17 raspberrypi systemd[1]: Got disconnect on private connection.
lut 24 14:06:17 raspberrypi dhcpcd[415]: eth0: soliciting an IPv6 router
lut 24 14:06:19 raspberrypi ntpd[506]: Listen normally on 4 eth0 192.168.0.79 UDP 123
lut 24 14:06:19 raspberrypi ntpd[506]: Listen normally on 5 eth0 fe80::ba27:ebff:fe8e:4ae3 UDP 123
lut 24 14:06:19 raspberrypi ntpd[506]: peers refreshed
lut 24 14:06:21 raspberrypi ntpd_intres[512]: DNS 0.debian.pool.ntp.org -> 94.154.96.7
lut 24 14:06:21 raspberrypi ntpd_intres[512]: DNS 1.debian.pool.ntp.org -> 195.46.37.22
lut 24 14:06:21 raspberrypi ntpd_intres[512]: DNS 2.debian.pool.ntp.org -> 193.106.216.30
lut 24 14:06:21 raspberrypi ntpd_intres[512]: DNS 3.debian.pool.ntp.org -> 194.177.4.2
lut 25 13:26:13 raspberrypi systemd[1]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
lut 25 13:26:13 raspberrypi systemd[520]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
lut 25 13:26:13 raspberrypi systemd[1]: Set up TFD_TIMER_CANCEL_ON_SET timerfd.
lut 25 13:26:13 raspberrypi systemd[1]: systemd-tmpfiles-clean.timer: time change, recalculating next elapse.
lut 25 13:26:13 raspberrypi systemd[1]: systemd-tmpfiles-clean.timer: Monotonic timer elapses in 14min 26.563229s.
lut 25 13:26:13 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1/unit/systemd_2dtmpfiles_2dclean_2etimer interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=117 reply_cookie=0 error=n/a
lut 25 13:26:13 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1/unit/systemd_2dtmpfiles_2dclean_2etimer interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=118 reply_cookie=0 error=n/a
lut 25 13:26:13 raspberrypi systemd[1]: Got notification message for unit systemd-journald.service
lut 25 13:26:13 raspberrypi systemd[1]: systemd-journald.service: Got notification message from PID 105 (WATCHDOG=1...)
lut 25 13:26:13 raspberrypi systemd[1]: systemd-journald.service: got WATCHDOG=1
lut 25 13:26:13 raspberrypi systemd[1]: Got notification message for unit systemd-journald.service
lut 25 13:26:13 raspberrypi systemd[1]: systemd-journald.service: Got notification message from PID 105 (WATCHDOG=1...)
lut 25 13:26:13 raspberrypi systemd-journal[105]: Forwarding to syslog missed 159 messages.
-- Subject: One or more messages could not be forwarded to syslog
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- One or more messages could not be forwarded to the syslog service
-- running side-by-side with journald. This usually indicates that the
-- syslog implementation has not been able to keep up with the speed of
-- messages queued.
lut 25 13:26:13 raspberrypi systemd[1]: systemd-journald.service: got WATCHDOG=1
lut 25 13:26:14 raspberrypi dhcpcd[415]: eth0: no IPv6 Routers available
lut 25 13:26:33 raspberrypi systemd[1]: Got notification message for unit systemd-logind.service
lut 25 13:26:33 raspberrypi systemd[1]: systemd-logind.service: Got notification message from PID 396 (WATCHDOG=1...)
lut 25 13:26:33 raspberrypi systemd[1]: systemd-logind.service: got WATCHDOG=1
lut 25 13:26:33 raspberrypi systemd[1]: Got notification message for unit systemd-logind.service
lut 25 13:26:33 raspberrypi systemd[1]: systemd-logind.service: Got notification message from PID 396 (WATCHDOG=1...)

 [...lots of these...]

lut 25 13:32:30 raspberrypi systemd[1]: systemd-logind.service: Got notification message from PID 396 (WATCHDOG=1...)
lut 25 13:32:30 raspberrypi systemd[1]: systemd-logind.service: got WATCHDOG=1
lut 25 13:32:30 raspberrypi systemd[1]: Got message type=method_call sender=:1.1 destination=org.freedesktop.systemd1 object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=StartTransientUnit cookie=27 reply_cookie=0 error=n/a
lut 25 13:32:30 raspberrypi systemd[1]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=GetConnectionUnixUser cookie=119 reply_cookie=0 error=n/a
lut 25 13:32:30 raspberrypi systemd[1]: Failed to load configuration for session-c2.scope: No such file or directory
lut 25 13:32:30 raspberrypi systemd[1]: Trying to enqueue job session-c2.scope/start/fail
lut 25 13:32:30 raspberrypi systemd[1]: Installed new job session-c2.scope/start as 194
lut 25 13:32:30 raspberrypi systemd[1]: Enqueued job session-c2.scope/start as 194
lut 25 13:32:30 raspberrypi systemd[1]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=120 reply_cookie=0 error=n/a
lut 25 13:32:30 raspberrypi systemd[1]: Sent message type=method_return sender=n/a destination=:1.1 object=n/a interface=n/a member=n/a cookie=122 reply_cookie=27 error=n/a
lut 25 13:32:30 raspberrypi systemd-logind[396]: New session c2 of user pi.
-- Subject: A new session c2 has been created for user pi
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A new session with the ID c2 has been created for the user pi.
--
-- The leading process of the session is 632.
lut 25 13:32:30 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitNew cookie=123 reply_cookie=0 error=n/a
lut 25 13:32:30 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobNew cookie=124 reply_cookie=0 error=n/a
lut 25 13:32:30 raspberrypi systemd[1]: Starting Session c2 of user pi.
-- Subject: Unit session-c2.scope has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-c2.scope has begun starting up.
lut 25 13:32:30 raspberrypi systemd[1]: session-c2.scope changed dead -> running
lut 25 13:32:30 raspberrypi systemd[1]: Job session-c2.scope/start finished, result=done
lut 25 13:32:30 raspberrypi systemd[1]: Started Session c2 of user pi.
-- Subject: Unit session-c2.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-c2.scope has finished starting up.
--
-- The start-up result is done.
lut 25 13:32:30 raspberrypi systemd[1]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RemoveMatch cookie=126 reply_cookie=0 error=n/a
lut 25 13:32:30 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1/unit/session_2dc2_2escope interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=127 reply_cookie=0 error=n/a
lut 25 13:32:30 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1/unit/session_2dc2_2escope interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=128 reply_cookie=0 error=n/a
lut 25 13:32:31 raspberrypi systemd[1]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=GetNameOwner cookie=121 reply_cookie=0 error=n/a
lut 25 13:32:31 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobRemoved cookie=125 reply_cookie=0 error=n/a
lut 25 13:32:33 raspberrypi sudo[657]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/bin/su
lut 25 13:32:33 raspberrypi sudo[657]: pam_unix(sudo:session): session opened for user root by pi(uid=0)
lut 25 13:32:33 raspberrypi su[664]: Successful su for root by root
lut 25 13:32:33 raspberrypi su[664]: + /dev/pts/0 root:root
lut 25 13:32:33 raspberrypi su[664]: pam_unix(su:session): session opened for user root by pi(uid=0)
lut 25 13:32:33 raspberrypi systemd[1]: Got message type=signal sender=org.freedesktop.DBus destination=n/a object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameOwnerChanged cookie=31 reply_cookie=0 error=n/a
lut 25 13:32:45 raspberrypi systemd[1]: Accepted new private connection.
lut 25 13:32:45 raspberrypi systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 object=/org/freedesktop/systemd1/unit/chromium_2eservice interface=org.freedesktop.DBus.Properties member=GetAll cookie=1 reply_cookie=0 error=n/a
lut 25 13:32:45 raspberrypi systemd[1]: Looking for unit files in (higher priority first):
lut 25 13:32:45 raspberrypi systemd[1]:         /etc/systemd/system
lut 25 13:32:45 raspberrypi systemd[1]:         /run/systemd/system
lut 25 13:32:45 raspberrypi systemd[1]:         /usr/local/lib/systemd/system
lut 25 13:32:45 raspberrypi systemd[1]:         /lib/systemd/system
lut 25 13:32:45 raspberrypi systemd[1]:         /usr/lib/systemd/system
lut 25 13:32:45 raspberrypi systemd[1]: Looking for SysV init scripts in:
lut 25 13:32:45 raspberrypi systemd[1]:         /etc/init.d
lut 25 13:32:45 raspberrypi systemd[1]: Looking for SysV rcN.d links in:
lut 25 13:32:45 raspberrypi systemd[1]:         /etc
lut 25 13:32:45 raspberrypi systemd[1]: Sent message type=method_return sender=n/a destination=n/a object=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 error=n/a
lut 25 13:32:45 raspberrypi systemd[1]: Collecting chromium.service
lut 25 13:32:45 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitNew cookie=2 reply_cookie=0 error=n/a
lut 25 13:32:45 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitNew cookie=129 reply_cookie=0 error=n/a
lut 25 13:32:45 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitRemoved cookie=3 reply_cookie=0 error=n/a
lut 25 13:32:45 raspberrypi systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnitRemoved cookie=130 reply_cookie=0 error=n/a
lut 25 13:32:45 raspberrypi systemd[1]: Got disconnect on private connection.
lut 25 13:33:13 raspberrypi systemd[1]: Got notification message for unit systemd-journald.service
lut 25 13:33:13 raspberrypi systemd[1]: systemd-journald.service: Got notification message from PID 105 (WATCHDOG=1...)
lut 25 13:33:13 raspberrypi systemd[1]: systemd-journald.service: got WATCHDOG=1
lut 25 13:33:13 raspberrypi systemd[1]: Got notification message for unit systemd-journald.service
lut 25 13:33:13 raspberrypi systemd[1]: systemd-journald.service: Got notification message from PID 105 (WATCHDOG=1...)
lut 25 13:33:13 raspberrypi systemd[1]: systemd-journald.service: got WATCHDOG=1

答案1

我会增加日志记录的详细程度以获取更多信息。然后在日志文件中 grep 查找 chromium 并向我们展示适当的片段。

为了增加详细程度,在/etc/systemd/system.conf

LogLevel=debug           <--- Uncomment this line and use "debug" (default: commented and "info")

我怀疑你的After=线路不正确?您当前的配置显示 chromium 在 getty 之后启动,但首先通过图形系统启用(读取安装)。

你希望 chromium 在图形系统启动后启动(事实上 chromium 会要求图形系统,所以我建议 在行Requires=后添加After=) 并且目标不应该 getty.targetgraphical.targetAfter=Requires=

希望增加日志的详细程度能够揭示这一点。我没有尝试过您正在尝试的操作,因此这纯粹是基于我对手册的解释的理论建议。

结语,似乎Install=可以工作,因为当您手动启动时(图形系统启动后),您说它工作正常。

答案2

  1. 将自定义服务创建为脚本

  2. 打开文件/etc/rc.d/rc.local

  3. 在文件行的末尾指向脚本文件位置,例如 sh /{文件路径}/{文件名}.sh

  4. 记住 /etc/rc.d/rc.local 和 /{path to file}/{filename}.sh 应该具有可执行权限

    注意:Linux系统使用/etc/rc.d/rc.local来运行最后一刻的自定义脚本

相关内容