Is there any Linux command to get various information like context switches of a process? Any solution other than ps will be appreciated.


A context switch counters are in /proc/$$/status:

As an example:

voluntary_ctxt_switches: 230 nonvoluntary_ctxt_switches: 35

You can get this easily by doing something similar to:

$ grep ctxt /proc/1234/status

| improve this answer | |
  • Interesting. I tried on few pid but they have no ctxt value. Will try on more pid. There is another command (#command pid) which shows useful information (context switch is one of them) just like the stat (#stat filename) command. It was a very nice utility which i forgot :( – al mamun Feb 21 '17 at 21:20
  • If you want rolling stats, look at pidstat -w 1 – Ed Neville May 20 '18 at 6:47

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