这是 systemd 服务模板/usr/local/lib/systemd/system/journal-split.service
:
[Unit]
Description=Journal Splitter Service / System Init Messages
Documentation=man:journalctl(1) man:systemd-journal-remote(8)
#RefuseManualStart=true
[Service]
Type=oneshot
RemainAfterExit=yes
User=root
Group=systemd-journal
ExecStart=/usr/local/lib/systemd/journal-split.sh
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target default.target
服务安装:
$ systemd-analyze verify journal-split.service
$ sudo systemctl daemon-reload
$ sudo systemctl enable journal-split.service
Created symlink /etc/systemd/system/multi-user.target.wants/journal-split.service → /usr/local/lib/systemd/system/journal-split.service.
Created symlink /etc/systemd/system/default.target.wants/journal-split.service → /usr/local/lib/systemd/system/journal-split.service.
$ sudo reboot
重启后,服务被加载但不执行:
$ systemctl status journal-split
○ journal-split.service - Journal Splitter Service / System Init Messages
Loaded: loaded (/usr/local/lib/systemd/system/journal-split.service; enabled; vendor preset: disabled)
Active: inactive (dead)
什么可能会阻止执行?
我可以使用手动执行该服务sudo systemctl start journal-split
并且它运行成功。