这里写自定义目录标题
一 kill指令
1. kill -9 进程号
强制进程马上停止
[root@localhost ~]# kill -9 22
[root@localhost ~]#
2. kill -15 进程号
优雅的关闭进程
3.kill -h
查找所有的进程序列号
二 pkill指令
kill方法的缺陷是,当我们有很多进程要杀死,不可能全部一个一个手动输进程号,pkill能够根据进程名称中的关键字去杀进程,这样就可以批量杀死了
- 杀掉所有带有python关键字的
pkill -9 python
- pkill -h
[root@localhost ~]# pkill -h
Usage:
pkill [options] <pattern>
Options:
-<sig>, --signal <sig> signal to send (either number or name)
-e, --echo display what is killed
-c, --count count of matching processes
-f, --full use full process name to match
-g, --pgroup <PGID,...> match listed process group IDs
-G, --group <GID,...> match real group IDs
-n, --newest select most recently started
-o, --oldest select least recently started
-P, --parent <PPID,...> match only child processes of the given parent
-s, --session <SID,...> match session IDs
-t, --terminal <tty,...> match by controlling terminal
-u, --euid <ID,...> match by effective IDs
-U, --uid <ID,...> match by real IDs
-x, --exact match exactly with the command name
-F, --pidfile <file> read PIDs from file
-L, --logpidfile fail if PID file is not locked
--ns <PID> match the processes that belong to the same
namespace as <pid>
--nslist <ns,...> list which namespaces will be considered for
the --ns option.
Available namespaces: ipc, mnt, net, pid, user, uts
-h, --help display this help and exit
-V, --version output version information and exit
For more details see pgrep(1).
三 进程的生命周期
进程时程序的一次执行过程,引入进程为了实现操作系统的并发性和实时性,一般点top的时候,就会看到这个数字一直在跳动,说明进程具有动态性。
主要有运行态,就绪态,阻塞态,创建态,结束态五种
进程描述信息分为两个部分:
- PID:进程标识符
- UID:用户标识符
一般kill的就是这个PID,PID是PCB的一个重要组成部分,而PCB作为一个整体