CentOS7上でサービス登録されたnginxを再起動する。
Redhat系OSのバージョン確認
$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
サービス操作
起動中のサービス一覧
$ sudo systemctl list-units --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
abrt-ccpp.service loaded active exited Install ABRT coredump hook
(省略)
docker.service loaded active running Docker Application Container Engine
nginx.service loaded active running The nginx HTTP and reverse proxy server
(省略)
サービス一覧の表示終了場合
「:」→「q」
nginxのサービスの状態を確認
$ sudo systemctl status nginx
* nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2020-08-17 13:54:51 JST; 20h ago
Process: 14867 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 14865 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 14863 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 14868 (nginx)
Tasks: 3
Memory: 7.6M
CGroup: /system.slice/nginx.service
|-14868 nginx: master process /usr/sbin/nginx
|-14869 nginx: worker process
`-14870 nginx: worker process
(省略)
nginxのサービスを停止
$ sudo systemctl stop nginx
nginxのサービスを起動
$ sudo systemctl start nginx
nginxのサービスを再起動
$ sudo systemctl restart nginx