Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dangtran09

macrumors newbie
Original poster
Nov 6, 2013
6
0
a brief summary -

i would like to check if an application has completely stop running by checking the %cpu. this application when not running is not at 0.0. it idles around ~ 0.4. however, sometimes i see the cpu dips below 0.4 or sometimes 0.0 for a brief second, then rebound higher. so my logic below would echo 'stop running' then exit out of the loop (which is not true because it dips quickly then rebound meaning app still running).

i have the following script, but not working as intended:

while :
do

num1=$(ps aux | grep "Name_of_APP" | head -1 | awk '{print $3}')

num2=0.4

if (( $(echo "$num1 > $num2" | bc -l) ));

then

echo "running"

else

echo "not running"



break

fi

done



is there a better solution?

thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.