I made this script to close a process, but I can't compare the awk result (var1) with an Integer: var1 -gt 5000.
My script:
#!/bin/bash
var1= free -m |awk 'NR == 2'| awk '{print $3}'
var2= ps aux | grep '/opt/skype/skype' | grep -v grep | awk '{print $2}'
while true;
do
if [ $var1 -gt 5000 ]; then
echo "La memoria se ha excedido cerrando porcesos"
kill -9 $var2
break
else
echo "La memoria aun es estable $var1"
fi
done
Could it be a casting problem in bash?
kill -0). Although in almost all instanceskill -9will end a process.