0

How do I get the process that is running currently on a Linux system? When I do a ps -aux, it returns me a list of several processes that are running on the machine.

But a processor can only run one process at a time, right? So how come so many processes run at the same time on the processor? Even if the context switch happens so fast, How can I get that just one process that is running at a given time on the CPU?

  • 2
    in ps aux output , there is a column specifying STAT , in you listing there must be a process with R STAT, this is that process running on CPU – mkmayank May 17 '18 at 10:32
3

In ps aux output , there is a column specifying STAT , in you listing there must be a process with R STAT, this is that process running on CPU

  • 1
    One of which invariably is ps itself. Or the only one, if you have a uniprocessor system. – ilkkachu May 17 '18 at 12:11
  • right, in uniprocessor system, whichever tool we used will become active process and will list itself as running, or am I missing something?? – mkmayank May 17 '18 at 12:12
  • Exactly. So it's not very useful. – ilkkachu May 17 '18 at 12:19
0

On Linux you have top command which supports focusing on a single process to monitor cpu and memory

top -pid PID

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.