国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > CentOS > 正文

CentOS 7.x設置自定義開機啟動,添加自定義系統服務

2024-06-28 13:19:10
字體:
來源:轉載
供稿:網友
CentOS 7.x設置自定義開機啟動,添加自定義系統服務

Centos 系統服務腳本目錄:

  1. /usr/lib/systemd/

有系統(system)和用戶(user)之分,

如需要開機沒有登陸情況下就能運行的程序,存在系統服務(system)里,即:

  1. /lib/systemd/system/

反之,用戶登錄后才能運行的程序,存在用戶(user)里

1  /lib/systemd/system   等于  /usr/lib/systemd/system2 /lib/systemd/user       等于  /usr/lib/systemd/user

服務以.service結尾。

這邊以nginx開機運行為例

1.建立服務文件

   

1 cd /lib/systemd/system/2 cp -p tuned.service httpd.service3 vim httpd.service

 1 [Unit] 2 Description=Apache Httpd Serveice 3 After=httpdlog.target 4  5 [Service] 6 Type=forking 7 ExecStart=/usr/local/apache2/bin/apachectl start 8 ExecReload=/usr/local/apache2/bin/apachectl restart 9 ExecStop=/usr/local/apache2/bin/apachectl stop10 PRivateTmp=true11 12 [Install]13 WantedBy=multi-user.target14 ~

[Unit]:服務的說明

Description:描述服務After:描述服務類別

[Service]服務運行參數的設置

Type=forking是后臺運行的形式ExecStart為服務的具體運行命令ExecReload為重啟命令ExecStop為停止命令PrivateTmp=True表示給服務分配獨立的臨時空間注意:[Service]的啟動、重啟、停止命令全部要求使用絕對路徑

[Install]服務安裝的相關設置,可設置為多用戶

2.保存目錄

以754的權限保存在目錄:

  1. /lib/systemd/system
3.設置開機自啟動

  1. systemctlenablenginx.service

4.其他命令

任務舊指令新指令
使某服務自動啟動chkconfig --level 3 httpd on systemctl enable httpd.service
使某服務不自動啟動chkconfig --level 3 httpd offsystemctl disable httpd.service
檢查服務狀態service httpd statussystemctl statushttpd.service (服務詳細信息)systemctl is-active httpd.service (僅顯示是否 Active)
顯示所有已啟動的服務chkconfig --listsystemctl list-units --type=service
啟動某服務service httpd startsystemctl start httpd.service
停止某服務service httpd stopsystemctl stop httpd.service
重啟某服務service httpd restartsystemctl restart httpd.service

啟動nginx服務

systemctlstartnginx.service

設置開機自啟動

systemctlenablenginx.service

停止開機自啟動

systemctldisablenginx.service

查看服務當前狀態

systemctlstatusnginx.service

重新啟動服務

systemctlrestartnginx.service

查看所有已啟動的服務

systemctllist-units--type=service

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 广平县| 泗水县| 永清县| 大石桥市| 普兰店市| 辛集市| 渝北区| 汉中市| 郸城县| 丽水市| 榆社县| 镇雄县| 闽侯县| 明星| 玉田县| 苍山县| 花莲县| 拉萨市| 宝应县| 安陆市| 岚皋县| 肥乡县| 塔城市| 玉屏| 台中市| 娱乐| 阿克陶县| 阜康市| 澄城县| 黔西县| 扶绥县| 郯城县| 汽车| 定南县| 志丹县| 镇宁| 灵武市| 彭水| 北辰区| 泾源县| 陆川县|