Skip to content

Instantly share code, notes, and snippets.

@olivertappin
Created November 27, 2019 16:51
Show Gist options
  • Save olivertappin/e2124880b2eabea9a7389724a910c81f to your computer and use it in GitHub Desktop.
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
#!/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