Skip to content

Instantly share code, notes, and snippets.

@fabioperrella
Created March 27, 2020 13:45
Show Gist options
  • Save fabioperrella/71b1724809349c1265ae293143213fc9 to your computer and use it in GitHub Desktop.
Save fabioperrella/71b1724809349c1265ae293143213fc9 to your computer and use it in GitHub Desktop.
Bash script to print the memory usage in syslog every 2s
#!/bin/bash
while :; do
mem_used="$(free -m | grep Mem | awk '{print$3}')"
mem_free="$(free -m | grep Mem | awk '{print$4}')"
mem_avail="$(free -m | grep Mem | awk '{print$4}')"
logger -t MemWatcher "Used: ${mem_used}. Free: ${mem_free}. Available: ${mem_avail}.";
sleep 2; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment