2013-10-11 12 views
11

serviceコマンドは、直接、適切なコマンドを呼び出すに比べて推奨される理由linuxでserviceコマンドを使う理由は?

service apache2 restart 

/etc/init.d/apache2 restart 

の違いはしたがって、基本的には何ですか?

+0

それはあなたの実際のLinuxディストリビューションに依存しますが、一部には、両方のと同じ効果を有することができます。 –

+2

これは、プログラミング上の問題ではないので、http://superuser.com/またはhttp://serverfault.com/またはhttp://unix.stackexchange.com/によく似ています。 – Jonik

+3

あなたがUbuntuを使用している場合、質問はここで答えられます:http://askubuntu.com/questions/2075/whats-the-difference-between-service-and-etc-init-dこれもサーバフォールト:http ://serverfault.com/questions/85621/to-restart-a-service-eg-httpd-should-i-use-etc-init-d-httpd-restart-or-sbi – Jonik

答えて

7

serviceコマンドは、予測可能な環境でのinitスクリプトを実行します:

サービスは、ほとんどの環境変数を削除し、できるだけ予測可能な環境で、System Vのinitスクリプトを実行し、/に設定された現在の作業ディレクトリで。

から:http://linux.die.net/man/8/service

関連する問題