pkill:通过进程名终止进程
简介pkill命令可以通过进程名终止指定的进程。使用killall命令终止进程需要连续执行几次,二pkill可以杀死指定进程及其所有子进程。
说明
pkill命令可以通过进程名终止指定的进程。使用killall命令终止进程需要连续执行几次,二pkill可以杀死指定进程及其所有子进程。
可以使用该命令来踢掉某个用户登录
格式
pkill [option] [pname]
常用参数
- -t 终端:杀死指定终端的进程
- -u 用户:杀死指定用户的进程
示例
1、杀死指定进程名称的进程
[root@localhost ~]# ps -aux|grep nginx #查看nginx进程
root 3212 0.0 0.1 45896 1304 ? Ss 00:44 0:00 nginx: master process /apps/nginx/sbin/nginx
nginx 3220 0.0 1.9 374796 20040 ? S 00:44 0:00 php-fpm: pool www
nginx 3221 0.0 1.8 374376 18384 ? S 00:44 0:00 php-fpm: pool www
nginx 3227 0.0 0.2 46756 2688 ? S 00:45 0:00 nginx: worker process
root 3508 0.0 0.0 112660 976 pts/0 S+ 03:46 0:00 grep --color=auto nginx
[root@localhost ~]# pkill nginx #终止nginx进程
[root@localhost ~]# ps -aux|grep nginx #nginx相关进程被终止了
nginx 3220 0.0 1.9 374796 20040 ? S 00:44 0:00 php-fpm: pool www
nginx 3221 0.0 1.8 374376 18384 ? S 00:44 0:00 php-fpm: pool www
root 3512 0.0 0.0 112660 664 pts/0 R+ 03:47 0:00 grep --color=auto nginx
2、指定用户名来杀死进程,一定要注意,不要使用root用户
#****本想杀死nginx这个用户的所有进程,结果没杀死,这里没搞懂,所以这里暂时不要使用******
[root@localhost ~]# ps -aux|grep nginx
nginx 2300 0.0 1.8 374376 18384 ? S 03:28 0:00 php-fpm: pool www
nginx 2301 0.0 1.8 374376 18384 ? S 03:28 0:00 php-fpm: pool www
root 2308 0.0 0.1 45896 1148 ? Ss 03:29 0:00 nginx: master process /apps/nginx/sbin/nginx
nginx 2309 0.0 0.2 46756 2192 ? S 03:29 0:00 nginx: worker process
root 2311 0.0 0.0 112660 976 pts/0 R+ 03:29 0:00 grep --color=auto nginx
[root@localhost ~]#
[root@localhost ~]# pkill -u nginx
[root@localhost ~]#
[root@localhost ~]# ps -aux|grep nginx
root 2308 0.0 0.1 45896 1308 ? Ss 03:29 0:00 nginx: master process /apps/nginx/sbin/nginx
nginx 2317 0.0 1.8 374376 18384 ? S 03:29 0:00 php-fpm: pool www
nginx 2318 0.0 1.8 374376 18384 ? S 03:29 0:00 php-fpm: pool www
nginx 2319 0.0 0.2 46756 2192 ? S 03:29 0:00 nginx: worker process
root 2321 0.0 0.0 112660 976 pts/0 S+ 03:29 0:00 grep --color=auto nginx
3、通过终端名称来终止进程
[root@localhost ~]# w
03:33:12 up 16 min, 2 users, load average: 0.00, 0.02, 0.05
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 03:17 0.00s 0.20s 0.00s w
root pts/1 03:31 8.00s 0.10s 0.07s top #该终端正在进行top命令
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# pkill -t pts/1 #杀死指定终端的进程,切换到另一个终端,top命令被结束了
4、通过指定用户名来终止进程,也就是踢掉用户一定要注意,不要使用root用户,这样必须要重启
#终止非root用户
[root@localhost ~]# w
03:35:48 up 19 min, 2 users, load average: 0.10, 0.04, 0.05
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 03:17 4.00s 0.21s 0.00s w
skip pts/2 03:35 13.00s 0.01s 0.01s -bash #skip用户登录了终端
[root@localhost ~]#
[root@localhost ~]# pkill -u skip #通过用户名来终止skip终端,skip的终端被强制退出了。
#终止其他以root用户登录的终端,使用-9加-t
[root@localhost ~]# w
03:41:09 up 24 min, 2 users, load average: 0.00, 0.01, 0.05
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 03:17 5.00s 0.22s 0.00s w
root pts/1 03:40 18.00s 0.01s 0.01s -bash
[root@localhost ~]#
[root@localhost ~]# pkill -9 -t pts/1 #这样,该终端就会被终止
[root@localhost ~]# w
03:41:27 up 25 min, 1 user, load average: 0.00, 0.01, 0.05
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 03:17 7.00s 0.23s 0.01s w
快速生成表格
OverflowBox组件运行子元素超出父容器的范围显示。当OverflowBox的最大尺寸大于子元素的时候,子元素可以完整显示,当小于子元素时候,就以最大尺寸为基准显示。最后需要加上对齐方式,完成布局。所以有些时候需要某个元素超过整个区域显示时候,就可以使用该组件。
Excel如何取最大值、最小值、排名第几的数据,这些都是在我们使用Excel中非常常用的功能。本文主要介绍下这几种函数的使用。
nodejs中使用npm和yarn,使用最新阿里云镜像 aliyun mirror,网上很多还是文章用的是下面这个地址~~yarn config set registry https://registry.npm.taobao.org~~
为了实现能定时修改桌面背景,又不想使用其他的软件,所以自己就通过了Python实现了更换桌面背景的程序,后期通过执行定时任务来修改自己的桌面背景。
Electron页面跳转、浏览器打开链接和打开新窗口
在使用Git的过程中,不想每次都输入用户名和密码去拉取代码,所以就需要保存这些信息,那么既然有保存了,就必须有清除功能。
Docker编译镜像出现:fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory问题
在Mac电脑中,如何对Git的用户名和密码进行修改呢?起初不懂Mac,所以整了很久,本文将记录如何对这个进行操作,以便后期使用。