Skip to content

Instantly share code, notes, and snippets.

@tjdahlke
Last active June 16, 2020 23:24
Show Gist options
  • Save tjdahlke/9a4746fd152bce79c2bb24465ea4ed1d to your computer and use it in GitHub Desktop.
Save tjdahlke/9a4746fd152bce79c2bb24465ea4ed1d to your computer and use it in GitHub Desktop.
A bash script to easily capture memory usage on a linux machine.
# Usage:
# ./track_memory.sh 100
# Which will record the memory usage (in Mb) for 100 seconds
#!/bin/bash
x=1
free -h| grep free > memory.txt
while [ $x -le $1 ]
do
free -m | grep Mem: >> memory.txt
echo "$x seconds of tracking memory"
x=$(( $x + 1 ))
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment