systemctl --now參數


1、我們安裝一個httpd服務來測試一下 --now參數

yum install httpd

2、查看一下當前服務狀態  可以看到服務沒有啟動 而且服務沒有自啟

[root@master1 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)
[root@master1 ~]#

[root@master1 ~]# systemctl is-enabled httpd
disabled
[root@master1 ~]#

3、用 --now參數啟動一下

systemctl enable --now httpd

4、我們在看一下狀態  可以看到服務啟動了 同時  也開機自啟了

[root@master1 conf]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-03-02 17:42:17 CST; 32s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 26736 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
    Tasks: 6
   Memory: 2.8M
   CGroup: /system.slice/httpd.service
           ├─26736 /usr/sbin/httpd -DFOREGROUND
           ├─26737 /usr/sbin/httpd -DFOREGROUND
           ├─26738 /usr/sbin/httpd -DFOREGROUND
           ├─26739 /usr/sbin/httpd -DFOREGROUND
           ├─26740 /usr/sbin/httpd -DFOREGROUND
           └─26741 /usr/sbin/httpd -DFOREGROUND

Mar 02 17:42:17 master1 systemd[1]: Starting The Apache HTTP Server...
Mar 02 17:42:17 master1 systemd[1]: Started The Apache HTTP Server.
Mar 02 17:42:17 master1 httpd[26736]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1...s message
Hint: Some lines were ellipsized, use -l to show in full.
[root@master1 conf]# systemctl is-enabled httpd.service
enabled
[root@master1 conf]#

5、同理如果用 systemctl disable --now httpd.service  去關閉服務 他會關閉服務的同時 去掉開機自啟

[root@master1 conf]# systemctl disable --now httpd.service
Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service.
[root@master1 conf]# systemctl is-enabled httpd.service
disabled
[root@master1 conf]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM