Shell script - Get CPU usage percentage of a process

To get the CPU usage percentage of a specific process, run the following command:

$ ps -o %C -p <PID> | tail -n 1


Example: to get CPU load of /usr/sbin/mysqld process which PID is 32241:

$ ps -o $C -p 32241 | tail -n 1

0.1

Comments