Hi,
I have a shell script. But, upon execution of the same, the cpu usage is sometimes getting 100 % (checked executing top command).
At that point of time, my process hangs, doesn't run anymore. I need to kill it manually.
My concern is, is there any default method, by which I can check each time, whether the CPU usage for my process reaches more than 90 % ?
ex-
if <<CPU usage> greater than 90 % >,
then
sleep 2
else
< normal execution >.
fi
Currently, I can do it, by taking the output of top command and parsing it (using awk or any similar tools). But, is there any better way to check that ?
Please help.
Thanks and Regards,
Jitendriya Dash.