Created
November 27, 2019 16:51
-
-
Save olivertappin/e2124880b2eabea9a7389724a910c81f to your computer and use it in GitHub Desktop.
Collect CPU usage statistics for the top 5 processes over a 60 second period
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 | |
OUTPUT=~/stats.txt; | |
for i in {0..120}; | |
do date >> $OUTPUT; | |
ps -Ao user,pid,pcpu,pmem,comm --sort=-pcpu | head -n6 >> $OUTPUT; | |
echo "" >> $OUTPUT; | |
sleep 0.5; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment