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 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. 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?? Commented May 17, 2018 at 12:12
  • Exactly. So it's not very useful. 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.