rhel/centos-6 initスクリプトでデーモンを起動する正規の方法は何ですか?

rhel/centos-6 initスクリプトでデーモンを起動する正規の方法は何ですか?

Ubuntu用のstart-stop-daemonに関する良い記事がたくさんあり、バイナリdaemon

しかし、私が知っている限り、rhel / centosスクリプトでデーモンを起動する正規の方法は、その/etc/init.d/functions関数を取得して使用することですdaemon()。しかし、良い例や文書が見つかりません。

rhel/centos-6 initスクリプトでデーモンを起動する正規の方法は何ですか?

私の最初の試みは次のとおりです。

#!/bin/bash
source /etc/init.d/functions
daemon --user USER nohup /path/to/your/binary arg1 arg2 >/dev/null 2>&1 &

ベストアンサー1

探しているドキュメントと例は/usr/share/doc/initscripts-*/sysvinitfilesCentOS / RHELにあります。以下は、その機能に関する特定の文書ですdaemon

デーモン [ --check ] [ --user ] [+/-nicelevel] プログラム [パラメータ] [&]

    Starts a daemon, if it is not already running.  Does
    other useful things like keeping the daemon from dumping
    core if it terminates unexpectedly.

    --check <name>:
       Check that <name> is running, as opposed to simply the
       first argument passed to daemon().
    --user <username>:
       Run command as user <username>

CentOS/RHEL 6 では、sysv init スクリプトを作成するのではなく、upstart ワークファイルを使用するオプションもあります。

おすすめ記事