daemon
完成service的程序稱為daemon,常見的service名稱,例如mysqld中的d既是的daemon的意思
查看本機所有的服務地址:/etc/lib/systemd/system
怎麼區分類型?
根據拓展名
.service:系統服務,大多數是這種類型
.socket:內部程序數據交換,通常會延遲啟動
.target:執行環境,一群unit的集合
.mount/.automount:文件系統掛載相關服務
.path:監測特定文件和類型
.timer:循環執行的服務
通過systemctl管理服務
管理單一服務的啟動、開機啟動、查看狀態
systemctl [command] [unit]
command主要有:
start: 立刻啟動後面的服務
stop: 立刻停止後面的服務
restart: 重啟後面的服務,即執行stop和start
reload: 不關閉服務,重新加載配置文件
enable:設置開機啟動
disable: 禁止開機啟動
status: 查看當前服務的設置
is-active: 目前有沒有運行這個服務
is-enable: 有沒有設置開機啟動
mask:註銷服務
[root@localhost system]# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: http://nginx.org/en/docs/
loaded:開機的時候這個服務會不會啟動,disable不會啟動,enable會啟動
Active:現在這個服務正在執行(running)獲取沒有執行(dead)
查看系統上的所有服務
systemctl [command] [--type=TYPE] [--all]
command:
list-units :依據unit顯示目前有啟動的unit,若加上--all才會列出沒啟動的
list-unit-files:列出/usr/lib/systemd/system內的文件