当前位置:首页 >> 服务器

Linux下如何查杀stopped进程详解

前言

在Linux系统下面,top命令可以查看查看stopped进程。但是不能查看stopped进程的详细信息。那么如何查看stopped 进程,并且杀掉这些stopped进程呢? 

 ps -e j | grep T 

Linux下如何查杀stopped进程详解

stopped进程的STAT状态为T,一般而言,进程有下面这些状态码:

               D    uninterruptible sleep (usually IO)

               I    Idle kernel thread

               R    running or runnable (on run queue)

               S    interruptible sleep (waiting for an event to complete)

               T    stopped by job control signal

               t    stopped by debugger during the tracing

               W    paging (not valid since the 2.6.xx kernel)

               X    dead (should never be seen)

               Z    defunct ("zombie") process, terminated but not reaped by
                    its parent

       For BSD formats and when the stat keyword is used, additional
       characters may be displayed: 

               <    high-priority (not nice to other users)

               N    low-priority (nice to other users)

               L    has pages locked into memory (for real-time and custom
                    IO)

               s    is a session leader

               l    is multi-threaded (using CLONE_THREAD, like NPTL
                    pthreads do)

               +    is in the foreground process group

一般较常见的是5种状态码:

     D 不可中断 uninterruptible sleep (usually IO)

     R 运行 runnable (on run queue)

     S 中断 sleeping

     T 停止 traced or stopped

     Z 僵死 a defunct (”zombie”) process 

所以,可以用下面命令ps -A -ostat,ppid,pid,cmd | grep -e '^[T]' 查看stopped的进程信息。如下所示:

# ps -A -ostat,ppid,pid,cmd | grep -e '^[T]'
 
T  6777 8635 more alert_pps.log
T  6777 9654 tail -60f alert_pps.log
T  6777 10724 top
# kill -9 8635
# ps -A -ostat,ppid,pid,cmd | grep -e '^[T]'
T  6777 9654 tail -60f alert_pps.log
T  6777 10724 top
# kill -9 9654
# kill -9 10724

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对的支持。