systemdテンプレートサービスの場合、ステータス出力はExecStartから%iを拡張しません。

systemdテンプレートサービスの場合、ステータス出力はExecStartから%iを拡張しません。

サービススクリプトは名前に%iが拡張されたbashスクリプトを正しく起動しますが、ステータスを要求すると%iは拡張されません。スクリプトは次のとおりです。

#cat /etc/systemd/system/[email protected]

# The test service unit template file
#
# version=$Header

[Unit]
Description=test %I instance

[Service]
Type=forking
KillMode=process
ExecStart=/bin/bash /tmp/test_service_script_%i 

#cat /tmp/test_service_script_fred

#!/bin/bash

sleep 300&
echo `date`Running $0 > $0.log

これを実行しても大丈夫です。

#systemctl start test@fred
#cat /tmp/test_service_script_fred.log

Thu 12 Oct 14:42:01 BST 2023Running /tmp/test_service_script_fred

これまでは大丈夫だったが、

#systemctl status test@fred[email protected] - test fred instance
    Loaded: loaded (/etc/systemd/system/[email protected]; static; vendor preset: disabled)
    Active: active (running) since Thu 2023-10-12 14:42:01 BST; 6s ago
    Process: 10442 ExecStart=/bin/bash /tmp/test_service_script_%i (code=exited, status=0/SUCCESS)
    CGroup: /system.slice/system-test.slice/[email protected]
           ├─ 9798 sleep 300
           ├─10247 sleep 300
           └─10443 sleep 300

"Process:" で始まる行には拡張されていない %i があります。

実行中のコンテンツを表示できるように拡張する必要がありますか?

ベストアンサー1

おすすめ記事