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?

1
  • 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
    – dgfjxcv
    Commented May 17, 2018 at 10:32

2 Answers 2

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

3
  • 1
    One of which invariably is ps itself. Or the only one, if you have a uniprocessor system.
    – ilkkachu
    Commented May 17, 2018 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??
    – dgfjxcv
    Commented May 17, 2018 at 12:12
  • Exactly. So it's not very useful.
    – ilkkachu
    Commented May 17, 2018 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .