Ps
From DikapediaV2
ps - report a snapshot of the current processes.
How to read PS (Basics)
Example:
$ ps PID TTY TIME CMD 8741 pts/0 00:00:00 bash 8863 pts/0 00:00:00 ps
- PID = Process ID
- pts = Psuedo Terminal Session
Show all processes running on the system:
$ ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 May10 ? 00:00:25 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 root 2 0 0 May10 ? 00:00:00 [kthreadd] root 4 2 0 May10 ? 00:00:00 [kworker/0:0H] root 5 2 0 May10 ? 00:00:01 [kworker/u4:0] root 6 2 0 May10 ? 00:00:00 [mm_percpu_wq] root 7 2 0 May10 ? 00:00:00 [ksoftirqd/0] root 8 2 0 May10 ? 00:00:08 [rcu_sched] root 9 2 0 May10 ? 00:00:00 [rcu_bh] root 10 2 0 May10 ? 00:00:00 [migration/0] root 11 2 0 May10 ? 00:00:00 [watchdog/0] root 12 2 0 May10 ? 00:00:00 [cpuhp/0] root 13 2 0 May10 ? 00:00:00 [cpuhp/1] root 14 2 0 May10 ? 00:00:00 [watchdog/1] root 15 2 0 May10 ? 00:00:00 [migration/1] root 16 2 0 May10 ? 00:00:00 [ksoftirqd/1] root 18 2 0 May10 ? 00:00:00 [kworker/1:0H]
- PPID = Parent PID
- ? = Process running as a daemon, not attached to the terminal.
- Commands in [] = Kernel threads
How to find the processor which a process is running on
1. Run the following commands and then review the output to determine the following:
- The process ID of the process. In this example, we are showing the aws-replication-agent process.
# pidof <process> # pidof /var/lib/aws-replication-agent/jre/bin/java
- The CPU core (indicated by psr) that it's running on.
# ps --pid $(pidof <process>) -o psr,pid,comm # ps --pid $(pidof /var/lib/aws-replication-agent/jre/bin/java) -o psr,pid,comm
Then, check the CPU utilization of the identified CPU core.
# mpstat -P <psr column value> 3