Linux服务进程管理

  • 服务管理
  • 进程管理

准备工作- 安装nginx服务

准备安装一个nginx 网站服务器,默认端口为80。用于测试目的

<pre style="margin-top:15px;margin-bottom:15px;padding:8px 4px 6px;max-width:100%;color:rgb(51,51,51);letter-spacing:.544px;font-size:.9em;white-space:normal;background-image:inherit;background-attachment:inherit;background-color:rgb(248,248,248);border-width:1px;border-style:solid;border-color:rgb(231,234,237);width:inherit;">yum -y install nginx

服务管理-systemctl

7 : systemctl 6: service

启动 : systemctl start nginx

停止: systemctl stop nginx


重启: systemctl restart nginx

重载: systemctl reload nginx

状态 : systemctl status nginx

开机自启 : systemctl enable nginx

开机禁止: systemctl disable nginx

服务验证

netstat 查看端口,tcp:-anlpt , udp: -anlpu

<pre style="margin-top:15px;margin-bottom:15px;padding:8px 4px 6px;max-width:100%;color:rgb(51,51,51);letter-spacing:.544px;font-size:.9em;white-space:normal;background-image:inherit;background-attachment:inherit;background-color:rgb(248,248,248);border-width:1px;border-style:solid;border-color:rgb(231,234,237);width:inherit;">[root@myserver ~]# netstat -anlpt | grep 80<br></br>tcp       0     0 0.0.0.0:80             0.0.0.0:*               LISTEN     6416/nginx: master  <br></br>tcp6       0     0 :::80                   :::*                   LISTEN     6416/nginx: master  <br></br>

进程管理

ps 查看进程状态

<pre style="margin-top:15px;margin-bottom:15px;padding:8px 4px 6px;max-width:100%;color:rgb(51,51,51);letter-spacing:.544px;font-size:.9em;white-space:normal;background-image:inherit;background-attachment:inherit;background-color:rgb(248,248,248);border-width:1px;border-style:solid;border-color:rgb(231,234,237);width:inherit;">[root@myserver ~]# ps aux |grep nginx<br></br>root       6416 0.0 0.5 118672 9920 ?       Ss   09:10   0:00 nginx: master process /usr/sbin/nginx<br></br>nginx       6447 0.0 0.4 150020 9000 ?       S   09:10   0:00 nginx: worker process<br></br>root       6635 0.0 0.0 12108 1088 pts/0   S+   09:15   0:00 grep --color=auto nginx<br></br><br></br>###<br></br>运行用户、进程id<br></br>

kill 停止进程, kill pid , -9 强制停止 -15 发送信号稳定停止

<pre style="margin-top:15px;margin-bottom:15px;padding:8px 4px 6px;max-width:100%;color:rgb(51,51,51);letter-spacing:.544px;font-size:.9em;white-space:normal;background-image:inherit;background-attachment:inherit;background-color:rgb(248,248,248);border-width:1px;border-style:solid;border-color:rgb(231,234,237);width:inherit;">kill pid<br></br>kill -9 123<br></br>kill -15 123<br></br>killall nginx   ## 将nginx服务的所有进程停止

top查看系统进程

标签: Linux, nginx, 进程, systemctl, 服务, grep, 运维, 教程

相关文章推荐

添加新评论,含*的栏目为必填