program memory monitor linux code example
Example 1: linux command to check memory usage in percentage
$ free -t | awk 'NR == 2 {printf("Current Memory Utilization is : %.2f%"), $3/$2*100}'
or
$ free -t | awk 'FNR == 2 {printf("Current Memory Utilization is : %.2f%"), $3/$2*100}'
Current Memory Utilization is : 20.42%
Example 2: free memory linux command
# sync; echo 1 > /proc/sys/vm/drop_caches