Is there any script to know the cpu load in linux
Hi,
I have written a script in linux that generate loads by creting files. I need to generate load until the CPU load reaches 100%. Please provide the script. Thanks, - Nick |
CPU load alone is not a good indicator of system load. The load value from top is better. However for cpu you could use something like
sar -u 1 1 > tst tail -1 tst | awk '{print $5}' This will actually give you the idle cpu percentage. When it reaches 0, your cpu is 100% in use somewhere else. |
Worth checking the output of sar -u 1 1 first
On my machine the % idle is the eight entry on the line. Also, there is no need to put the data into a file: Code:
sar -u 1 1|tail -1|awk '{print $8}' |
fyi: Not all systems have sar.
you can use top in a script like so: Code:
top n 1 > some_var As alternatives, there are iostat and mpstat. You can always use uptime as well & look for a 1 second load average of 1.00 which may or may not be reliable enough for your purposes. |
All times are GMT -5. The time now is 05:19 PM. |