web-dev-qa-db-ja.com

CentOSでchkconfigを使用してサービスを作成するにはどうすればよいですか?

サーバーが起動するたびにbashスクリプトが実行されるようにサービスを作成できるようにしたい。

CentOS5を実行しています。

私はchkconfigについて読んでいて、chkconfigが処理するために/etc/init.dにファイルを作成していますが、「chkconfig servicename on」、「service servicenamestart」の順に実行するたびに機能しないようです。

Chkconfig --listを実行すると、サービスがそこにリストされます。

/etc/init.dに作成する必要のあるファイルのサンプルと、すべてを実行する方法を誰かに教えてもらえますか?

5
qroberts

サーバーが起動するたびに1つ以上の処理を実行するbashスクリプトが必要な場合は、/ etc/rc.localからスクリプトを実行できます。これが私のものです-起動スクリプトを呼び出すことでメディアサーバーアプリを起動します。

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

#NK make sure nas is mounted:
mount -a
/etc/init.d/serviiod start
4
Linker3000

Fedora ProjectのWebサイトに initscriptテンプレート があります。

同じページのテンプレートの下に、RedHat/Fedora/CentOSシステムでinitscriptsのヘッダーを作成するための完全な手順があります。他のサービスが開始された後にスクリプトを確実に実行する必要がある場合、特定の状況でのみスクリプトを実行する場合、またはグラフィカルシステム管理ツールでスクリプトに関する完全な情報を表示する場合は、これを行う必要があります。

7
Patches

スクリプト(例:(dctm、dctm_jms))をパス/etc/init.dに配置します

chmod +x dctm
chmod +x dctm_jms
chkconfig --add dctm
chkconfig --add dctm_jms
chkconfig --level 345 dctm on
chkconfig --level 345 dctm_jms on
2
Jesus villajos