手動で開始されたsystemdサービスを作成して有効にしましたが、再起動後に自動的に開始されません。自動的に起動しない理由はどうすればわかりますか?

手動で開始されたsystemdサービスを作成して有効にしましたが、再起動後に自動的に開始されません。自動的に起動しない理由はどうすればわかりますか?

TmuxはCLIアプリケーションを起動するsystemdサービスを作成して有効にしましたが(SELinuxは無効にする必要があります)、再起動後にサービスを手動で開始する必要があります。自動的に起動しない理由はどうすればわかりますか?

サービスに関するいくつかの情報は次のとおりです。

[itadmin@SRV-LNX-RHEL01 ~]$ systemctl cat aescripts-LicenseServer.service 
# /etc/systemd/system/aescripts-LicenseServer.service
[Unit]
Description="Service that keeps runing the aescripts license server from startup."
[Install]
WantedBy=rescue.target
[Service]
User=itadmin
Type=forking
ExecStart=/usr/bin/tmux new-session -s itadmin -d bash -c '/home/itadmin/Dev/aescriptsLicenseServer_v3.5.6/Linux/aescriptsLicenseServer'
WorkingDirectory=/home/itadmin/Dev/aescriptsLicenseServer_v3.5.6/Linux
Restart=always
RestartSec=5
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n

[itadmin@SRV-LNX-RHEL01 ~]$ systemctl status aescripts-LicenseServer.service 
● aescripts-LicenseServer.service - "Service that keeps runing the aescripts license server from s>
   Loaded: loaded (/etc/systemd/system/aescripts-LicenseServer.service; enabled; vendor preset: di>
   Active: active (running) since Tue 2021-10-05 17:21:04 PDT; 5min ago
  Process: 7723 ExecStart=/usr/bin/tmux new-session -s itadmin -d bash -c /home/itadmin/Dev/aescri>
 Main PID: 7725 (tmux: server)
    Tasks: 2 (limit: 8144)
   Memory: 2.3M
   CGroup: /system.slice/aescripts-LicenseServer.service
           ├─7725 /usr/bin/tmux new-session -s itadmin -d bash -c /home/itadmin/Dev/aescriptsLicen>
           └─7726 /home/itadmin/Dev/aescriptsLicenseServer_v3.5.6/Linux/aescriptsLicenseServer

Oct 05 17:21:04 SRV-LNX-RHEL01 systemd[1]: Starting "Service that keeps runing the aescripts licen>
Oct 05 17:21:04 SRV-LNX-RHEL01 systemd[1]: Started "Service that keeps runing the aescripts licens>

[itadmin@SRV-LNX-RHEL01 ~]$ systemctl list-dependencies aescripts-LicenseServer.service 
aescripts-LicenseServer.service
● ├─-.mount
● ├─home.mount
● ├─system.slice
● └─sysinit.target
●   ├─dev-hugepages.mount
●   ├─dev-mqueue.mount
●   ├─dracut-shutdown.service
●   ├─import-state.service
●   ├─iscsi-onboot.service
●   ├─kmod-static-nodes.service
●   ├─ldconfig.service
●   ├─loadmodules.service
●   ├─lvm2-lvmpolld.socket
●   ├─lvm2-monitor.service
●   ├─multipathd.service
●   ├─nis-domainname.service
●   ├─plymouth-read-write.service
●   ├─plymouth-start.service
●   ├─proc-sys-fs-binfmt_misc.automount
●   ├─selinux-autorelabel-mark.service
●   ├─sys-fs-fuse-connections.mount
●   ├─sys-kernel-config.mount
●   ├─sys-kernel-debug.mount
●   ├─systemd-ask-password-console.path
●   ├─systemd-binfmt.service
●   ├─systemd-firstboot.service
●   ├─systemd-hwdb-update.service
●   ├─systemd-journal-catalog-update.service
●   ├─systemd-journal-flush.service
●   ├─systemd-journald.service
●   ├─systemd-machine-id-commit.service
●   ├─systemd-modules-load.service
●   ├─systemd-random-seed.service
●   ├─systemd-sysctl.service
●   ├─systemd-sysusers.service
●   ├─systemd-tmpfiles-setup-dev.service
●   ├─systemd-tmpfiles-setup.service
●   ├─systemd-udev-trigger.service
●   ├─systemd-udevd.service
●   ├─systemd-update-done.service
●   ├─systemd-update-utmp.service
●   ├─cryptsetup.target
●   ├─local-fs.target
●   │ ├─-.mount
●   │ ├─boot-efi.mount
●   │ ├─boot.mount
●   │ ├─home.mount
●   │ └─systemd-remount-fs.service
●   └─swap.target
●     └─dev-mapper-rhel\x2dswap.swap

ベストアンサー1

サービスは回復モードで起動したときにのみ開始されます。

[Install]
WantedBy=rescue.target
rescue.target

    A special target unit that pulls in the base system (including system mounts) and spawns a rescue shell. Isolate to this target in order to administer the system in single-user mode with all file systems mounted but with no services running, except for the most basic.

(からhttps://www.freedesktop.org/software/systemd/man/systemd.special.html#rescue.target)。

multi-user.targetが有効になったら、サービスを開始したいと思います。

multi-user.target

    A special target unit for setting up a multi-user system (non-graphical). This is pulled in by graphical.target.

    Units that are needed for a multi-user system shall add Wants= dependencies for their unit to this unit during installation. This is best configured via WantedBy=multi-user.target in the unit's [Install] section.

https://www.freedesktop.org/software/systemd/man/systemd.special.html#multi-user.target)

おすすめ記事