在哪里可以找到由 systemd 启动的进程的命令行,以便调试它?

Where can I find the command line of a process started by systemd so I can debug it?

当守护进程 foo 由 systemd 启动时,它会按照下面的消息失败,守护进程抱怨使用了无效的命令行选项(通过 "journalctl -xe")。

Feb 21 23:46:05 localhost systemd[1]: Starting The Foo Server...
-- Subject: Unit foo.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit foo.service has begun starting up.
Feb 21 23:46:05 localhost food[6709]: Usage: /usr/sbin/food [options]

如何让 systemd 记录正在使用的命令行以便调试此错误?

如果您将 systemd 的日志记录配置为 "debug" 级别,您会看到如下消息:

"abc.service: Executing /bin/true arg arg arg"

LogLevel=debug 就够了。看看https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html

应用更改的最简单方法是重新启动 systemd。