When I execute shell scripts bash.sh like this:
for((i = 0; i<=5 ;i++))
do
./test.sh &
done
and test.sh like this:
for((i = 0; i<=10000000 ;i++))
do
echo 'hh'
done
the cpu us usage should be very high.
But when I use top command to check the result, the cpu us value of the very first time of the top command result, before it refreshes, is very small.
So the cpu usage is not credible!
Are the other values credible the first time top command result refresh?
The load average
reported on the top right is the average over the last 1, 5 and 15 minutes (from the man top
page):
system load avg over the last 1, 5 and 15 minutes
So this value will be averaged over the last minute, and as a result your process with a high CPU usage will not have an immediate effect on it.
The %CPU
column shows the usage since the last update:
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time
So on the first time, the %CPUs are off and will change when the screen updates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With