linux에서 ps 명령을 통해 프로세스별 CPU 사용량 확인해보기
ps -aux --sort -pcpu
$ ps -aux --sort -pcpu|more
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1014 0.1 0.1 2085844 49692 ? Ssl Oct02 3:37 /usr/bin/containerd
root 5678 0.1 1.8 15310052 738596 pts/0 Ssl+ Oct02 5:30 java -Dspring.profiles.active=prod -jar app.jar
root 1 0.0 0.0 167908 11636 ? Ss Oct02 0:11 /sbin/init splash
root 2 0.0 0.0 0 0 ? S Oct02 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< Oct02 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< Oct02 0:00 [rcu_par_gp]
root 5 0.0 0.0 0 0 ? I< Oct02 0:00 [netns]
root 7 0.0 0.0 0 0 ? I< Oct02 0:00 [kworker/0:0H-events_highpri]
root 9 0.0 0.0 0 0 ? I< Oct02 0:00 [kworker/0:1H-kblockd]
head 명령을 통해 결과 개수 조정
$ ps -aux --sort -pcpu|head -n 11
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1014 0.1 0.1 2085844 49692 ? Ssl Oct02 3:37 /usr/bin/containerd
root 5678 0.1 1.8 15310052 738596 pts/0 Ssl+ Oct02 5:30 java -Dspring.profiles.active=prod -jar app.jar
root 1 0.0 0.0 167908 11636 ? Ss Oct02 0:11 /sbin/init splash
root 2 0.0 0.0 0 0 ? S Oct02 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< Oct02 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< Oct02 0:00 [rcu_par_gp]
root 5 0.0 0.0 0 0 ? I< Oct02 0:00 [netns]
root 7 0.0 0.0 0 0 ? I< Oct02 0:00 [kworker/0:0H-events_highpri]
root 9 0.0 0.0 0 0 ? I< Oct02 0:00 [kworker/0:1H-kblockd]
root 10 0.0 0.0 0 0 ? I< Oct02 0:00 [mm_percpu_wq]