systemd:使用 sh -c exec idiom 关于进程名称的谎言

mwp*_*mwp 4 systemd systemd-journald

sh -c execExecStart语句中(在服务单元文件中)使用习语来插入一些 shell 命令。例如:

ExecStart=/bin/sh -ec "exec /usr/bin/foo $(/usr/bin/foo-config)"
Run Code Online (Sandbox Code Playgroud)

它工作得很好。但是,当我查看此服务的日志时,进程名称sh不是foo. 有没有办法使用这个习语来对进程名称撒谎?

mwp*_*mwp 6

啊,结果证明这比我想象的要容易得多。在这里找到答案:https : //unix.stackexchange.com/a/229525/11995

    SyslogIdentifier=foo
Run Code Online (Sandbox Code Playgroud)