Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

在 RedHat 與 CentOS 用 service 管理自訂服務

建立 init 腳本

若自行安裝 nginx 等服務,想使用 service 指令啟動或關閉,可在 /etc/init.d 建立對應腳本。腳本中需包含 chkconfig 參數,說明開機級別與排序。

加入 chkconfig

先給腳本執行權限,再用 chkconfig --add 加入服務。若出現不支援 chkconfig 的訊息,通常是缺少 chkconfig 設定行。

設定開機啟動

可用 chkconfig --level 35 指定在 3 與 5 級啟動,之後即可用 service nginx start 或 stop 管理。這讓自訂服務更容易整合進系統流程。

Copyright © Linux教程網 All Rights Reserved