Linux怎么查看nginx啟動(dòng)狀態(tài)

小億
381
2024-01-12 13:42:01

要查看nginx的啟動(dòng)狀態(tài),可以使用以下命令:
1. 使用`systemctl`命令(適用于使用systemd管理的系統(tǒng)):

  systemctl status nginx

這將顯示nginx的當(dāng)前狀態(tài),包括是否正在運(yùn)行和已運(yùn)行的時(shí)間。
2. 使用`service`命令(適用于使用init管理的系統(tǒng)):

  service nginx status

這將顯示nginx的當(dāng)前狀態(tài),包括是否正在運(yùn)行和已運(yùn)行的時(shí)間。
3. 使用`ps`命令查找nginx進(jìn)程:

  ps aux | grep nginx

這將顯示正在運(yùn)行的nginx進(jìn)程的詳細(xì)信息,包括進(jìn)程ID(PID)和啟動(dòng)命令。
無(wú)論使用哪種方法,如果nginx正在運(yùn)行,您將看到類似以下內(nèi)容的輸出:

nginx.service - The nginx HTTP and reverse proxy server

   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)

   Active: active (running) since Wed 2022-02-09 09:35:57 UTC; 3s ago

     Docs: http://nginx.org/en/docs/

 Main PID: 12345 (nginx)

    Tasks: 2 (limit: 2361)

   Memory: 3.2M

   CGroup: /system.slice/nginx.service

           ├─12345 nginx: master process /usr/sbin/nginx -g daemon on; master_process on

           └─12346 nginx: worker process

如果nginx沒(méi)有運(yùn)行,您將看到類似以下內(nèi)容的輸出:

nginx.service - The nginx HTTP and reverse proxy server

   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)

   Active: inactive (dead)

     Docs: http://nginx.org/en/docs/

0