Linux如何列出停止的进程?
通过执行“jobs”命令如下
# jobs [1]+ Stopped yum whatprovides */python-deltarpm
此命令将列出所有处于停止状态的进程
Linux如何强行停止进程?
我们可以使用“Ctrl + Z”强制停止进程,如下所示
# yum whatprovides */python-deltarpm Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Repository RHEL is listed more than once in the configuration RHEL | 2.9 kB 00:00:00 RHEL/primary_db | 3.7 kB 00:00:00 RHEL/filelists_db | 2.2 kB 00:00:00 No matches found ^Z [1]+ Stopped yum whatprovides */python-deltarpm
以这种方式停止并不意味着进程被杀掉。
如果现在我看到进程列表
# ps aux | grep -i yum root 10511 2.8 1.7 422324 71476 pts/2 T 19:09 0:00 /usr/bin/python /usr/bin/yum whatprovides */python-deltarpm
可以看到状态显示为“T”,这意味着已停止(Terminated)。
Linux如何杀死一个停止的进程?
这里我们需要使用分配给每个停止的进程的标识符。
在我们的例子中,我们看到标识符是 [1]
所以杀死这个特定的进程的命令是
# kill %1 [1]+ Stopped yum whatprovides */python-deltarpm
现在,如果我尝试查看已停止进程的列表
# jobs [1]+ Exit 1 yum whatprovides */python-deltarpm
正如我们在上面看到的那样,现在它正在尝试退出
几秒钟后再次执行命令
# jobs
没有输出,表明停止的进程已经没有了。
日期:2020-06-02 22:16:59 来源:oir作者:oir