RHEL7的服務

█RHEL7的服務systemctl腳本存放在:/usr/lib/systemd/,每個服務以 .server結尾,通常會分爲3個部分:[Unit]、[Service] 和 [Install]
ide

[Unit]部分:主要是對這個服務的說明,內容包括Description和After,Description用於描述服務,After用於描述服務類別spa

[Service]部分:是服務的關鍵,是服務的一些具體運行參數的設置, 這裏Type=forKing是後臺運行的 形式,PIDFile爲存放PID的文件路徑,ExecStart爲服務的具體運行命令,ExecReload爲重載命令,ExecStop爲中止命令rest

[Install]部分:是服務安裝的相關設置,可設爲多用戶的server

●systemctl命令的基本操做格式:systemctl 動做 服務名.service進程

●分析系統狀態ip

systemctl 或 systemctl list-units    #輸出激活的單元it

systemctl list-units --type=service     #列出active狀態的服務
io

systemctl list-units-files     #列出全部已安裝的服務class

systemctl --failed      #顯示啓動失敗的服務後臺

systemd-cgls     #以樹形列出正在運行的進程

全部可用的單元文件存放在/usr/lib/systemd/system/  和  /etc/systemd/system/目錄(後者優先級更高)

●使用單元

systemctl start <單元>    #當即啓動單元

systemctl stop <單元>     #當即中止單元

systemctl restart <單元>      #重啓單元

systemctl reload <單元>      #從新讀取單元配置

systemctl status <單元>      #輸出單元運行狀態

systemctl is-enabled <單元>      #檢查單元是否配置爲自動啓動

systemctl enable <單元>     #開機自動啓動單元

systemctl disabled <單元>      #取消開機自動激活單元

systemctl is-active <單元>      #查看單元是否是正在運行

systemctl daemon-reload       #從新載入systemd,掃描新的或有變更的單元

systemctl mask <單元>     #禁用指定服務

systemctl unmask <單元>       #激活指定服務

●電源管理

systemctl reboot      #重啓

systemctl poweroff       #退出系統並中止電源

相關文章
相關標籤/搜索