I need to measure my CPU percentage usage and memory.
Using top command will give this result (see the red sign)
Another command by typing
top -d 1 | grep -w "CPU"
How do i grab the percent value of cpu usage to a variable in bash linux?
Need help everyone :)
Many thanks
To get the CPU
percentage value you can use top -n1 -b
command and pipe it to awk
:
top -n 1 -b | awk '/^%Cpu/{print $2}'