如何使用自定义参数运行守护进程

fly*_*r88 3 configuration init daemon

我想知道如何使用自定义参数运行守护进程,在本例中为 NTP。

例如,在我的 Ubuntu PC 中,我观察到我ntpd以这种方式运行:

$ ps aux | grep ntpd
ntp  5936  ...  0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 119:127
Run Code Online (Sandbox Code Playgroud)

您可能会注意到该-g参数。

但是在我的 Gentoo PC 中,我运行了相同的命令,我可以观察到 ntp 守护进程没有使用该-g参数运行,我想添加它!

这是发行版特定的问题吗?我该如何处理?

sr_*_*sr_ 6

从猜测Gentoo的维基,编辑NTPD_OPTS/etc/conf.d/ntpd(如果不考虑这个问题大概开了窍-g是可取的,不知道)。


enz*_*tib 5

在 Debian 和 Ubuntu 中,守护进程通常在 中设置一些配置参数/etc/default/daemon-name,例如/etc/default/ntp

NTPD_OPTS='-g'
Run Code Online (Sandbox Code Playgroud)

该文件来自/etc/init.d/ntp,并恰如其分地使用了相应变量的值:

# near the beginning

if [ -r /etc/default/ntp ]; then
    . /etc/default/ntp
fi

# later

start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON \
    -- -p $PIDFILE $NTPD_OPTS
Run Code Online (Sandbox Code Playgroud)

不知道Gentoo有没有类似的。