Results 1 to 3 of 3
I would like to know the % free memory and the % busy . Is it possible with bash?
I have this:
#! /bin/bash
clear
MEMTOTAL=`free | grep Mem | ...
- 11-07-2008 #1Just Joined!
- Join Date
- Oct 2008
- Posts
- 48
memory en linux
I would like to know the % free memory and the % busy. Is it possible with bash?
I have this:
#! /bin/bash
clear
MEMTOTAL=`free | grep Mem | awk '{ print $2 }'`
MEMUSED=`free | grep Mem | awk '{ print $3 }'`
MEMFREE=`free | grep Mem | awk '{ print $4 }'`
echo "Total: "`expr $MEMTOTAL / 1024`"Mb" "($MEMTOTAL Kb)"> file.txt
echo "Usada: "`expr $MEMUSED / 1024`"Mb" "($MEMUSED Kb)" >> file.txt
echo "Libre: "`expr $MEMFREE / 1024`"Mb" "($MEMFREE Kb)" >> file.txt
echo " " >> file.txt
more "file.txt"
thanks!
- 11-07-2008 #2Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Code:free | awk '/^Mem:/ { print "used: " 100*$3/$2 "% free: " 100*$4/$2 "%"; }'
- 11-07-2008 #3Just Joined!
- Join Date
- Oct 2008
- Posts
- 48
i change a little:
[guif@jirabck Escritorio]$ free | awk '/Mem:/ {print "used: " 100*$3/$2 "%";}'
used: 97,2066%
[guif@jirabck Escritorio]$
[guif@jirabck Escritorio]$ free | awk '/Mem:/ {print "free: " 100*$4/$2 "%";}'
free: 2,79499%
this is correct???
and, in my code:
echo "`expr $MEMTOTAL / $MEMFREE`"%"
this is the used memory??? the result is different!


Reply With Quote