总目录:Linux操作整理
Linux中查看并管理运行的程序
查看所有运行的程序
(base) root@sayasora-linux:~# ps -elf
查看所有运行的python程序
(base) root@sayasora-linux:~# ps -elf |grep python
0 S root 4482 1 5 80 0 - 14784 poll_s Aug31 ? 16:16:53 python -u bilibili.py
0 S root 19444 19409 0 80 0 - 3555 pipe_w 21:34 pts/0 00:00:00 grep --color=auto python
|grep python也就是通过正则表达式过滤出所有运行程序中含有python字段的进程,返回结果最右边的也就是运行的python文件名,需要记住其对应的号码,如bilibili.py对应4482这个号码。
结束进程
(base) root@sayasora-linux:~# ps -elf |grep python
0 S root 4482 1 5 80 0 - 14784 poll_s Aug31 ? 16:16:53 python -u bilibili.py
0 S root 19444 19409 0 80 0 - 3555 pipe_w 21:34 pts/0 00:00:00 grep --color=auto python
(base) root@sayasora-linux:~# kill 4482
(base) root@sayasora-linux:~# ps -elf |grep python
0 S root 19451 19409 0 80 0 - 3555 pipe_w 21:39 pts/0 00:00:00 grep --color=auto python
输入kill 4482后,再次查看所有运行的python进程,证实bilibili.py已经被关闭。