Find all the sleeping processes

Hello today, i am going to show you how you can find all the processes that are sleeping.

First you need to see what are the fields in ps command.

Execute ps -aux | less

this shows you all the fields on top which you can use later.

Now using awk and pipes, we grab all the process with state “S” for sleeping or “D” for processes in uninterruptible sleep.

Command:

ps -eo state,pid,command | awk ‘{if($1==”S” || $1==”D”) print($1,$2,$3)}’

ps -eo state,pid,command shows every process (-e) with output formatted with (-o) to get desired output format.

So, this command outputs every process in mentioned format.

|| -> It is the pipes in linux

awk is used to manipulate data. if else condition is same as other language.

$1 is the first filed in output, $2 is the second and $3 is the third.

Command:

awk ‘{if($1==”S” || $1==”D”) print($1,$2,$3)}’

This command manipulates output with our condition to see if it has state S or D and print it.

要查看或添加评论,请登录

Prabesh .的更多文章

  • Why should everyone in the team be involved in the recruitment process?

    Why should everyone in the team be involved in the recruitment process?

    Hello everyone, I wanted to share some interesting things that happened to me in the workplace. I am sure this has…

    1 条评论
  • Why should you be honest in an IT interview?

    Why should you be honest in an IT interview?

    I have faced this and most of you might have as well. Today, I wanted to share some learning experiences that I faced…

    5 条评论
  • What is container and what is docker?

    What is container and what is docker?

    What is docker? It is a powerful tool which allows devops (system administrator, developers) to deploy application from…

  • Are docker containers secure by default?

    Are docker containers secure by default?

    Short answer No, is it is not more secure by default. But, we can make container secure by implementing various…

  • Could not get lock /var/lib/dpgk/lock-front end

    Could not get lock /var/lib/dpgk/lock-front end

    When you are new to Linux, you might bump into following error and can be frustrating if you don’t know what actually…

  • kill -15 vs kill -9

    kill -15 vs kill -9

    When we issue kill -15 which in Linux is called SIGTERM. A SIGTERM means termination signal.

  • Dissecting DIG command

    Dissecting DIG command

    Dig stands for Domain Information Groper. As the name suggests it is used to grab information from DNS server.

  • Why "Systemd" outperformed "Init" ?

    Why "Systemd" outperformed "Init" ?

    Before answering this question let me first give an overview what both of these mean. SysVinit: It is a Linux process…

    2 条评论
  • Special permissions (SetUID, SetGID, Stickybit)

    Special permissions (SetUID, SetGID, Stickybit)

    Have you ever thought why normal user can issue passwd command even when user is not the owner of /usr/bin/passwd nor…

  • Background jobs/process handling

    Background jobs/process handling

    I was going through my old notes where i came to know about running background jobs starting, stopping, suspending and…

社区洞察

其他会员也浏览了