系统实例名称(%i)在ExecStart中不起作用

出于某种原因,systemd不会用ExecStart中的实例名称replace%i%I


/systemd/system/service/[email protected]

 [Unit] Description=Foo service for %I [Service] User=keith ExecStart=/path/to/foo/%i/food ... 

/path/到/富/酒吧/食品

 #/bin/bash node /path/to/foo/bar/bard.js 

然后我运行:

 $ sudo systemctl daemon-reload $ sudo systemctl start foo@bar $ sudo systemctl status foo@bar ● [email protected] - Foo service for bar Loaded: loaded (/etc/systemd/system/[email protected]; disabled; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2016-09-30 19:07:02 EDT; 6s ago Process: 18705 ExecStart=/path/to/foo/%i/food (code=exited, status=203/EXEC) Main PID: 18705 (code=exited, status=203/EXEC) Sep 30 19:07:02 kptow systemd[1]: Started Foo service for bar. Sep 30 19:07:02 kptow systemd[1]: [email protected]: Main process exited, code=exited, status=203/EXEC Sep 30 19:07:02 kptow systemd[1]: [email protected]: Unit entered failed state. Sep 30 19:07:02 kptow systemd[1]: [email protected]: Failed with result 'exit-code'. 

描述中的%I会被replace,但ExecStart中的%i不会。 我试过使用%i / %I ,但都没有作用。

ExecStart=的第一个参数必须是可执行文件的绝对path。 replace不被接受。

如果你只是加载一个bash脚本,然后启动Node.js,你可以明确地做到这一点:

 ExecStart=/bin/bash /path/to/foo/%i/food