Last active
December 28, 2015 06:47
-
-
Save afunTW/3a69fef1fca4d342bad0 to your computer and use it in GitHub Desktop.
dump memory usage per min
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Recording memory usage to memoryLog..." | |
date >> memLog.csv | |
echo "USER,%CPU,%MEM,STIME,COMMAND" >> memLog.csv | |
while true; do | |
ps -ax -o user,pcpu,pmem,stime,cmd --sort -rss | head -n 6 >> tmpLog | |
while read -r user cpu mem stime cmd; do | |
if [ $user != "USER" ]; then | |
echo $user,$cpu,$mem,$stime,$cmd >> memLog.csv | |
fi | |
done < tmpLog | |
rm -f tmpLog | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment