Skip to content

Instantly share code, notes, and snippets.

@Bludwarf
Created July 8, 2024 14:06
Show Gist options
  • Save Bludwarf/345f1668ee83f5df0975c392085d61cb to your computer and use it in GitHub Desktop.
Save Bludwarf/345f1668ee83f5df0975c392085d61cb to your computer and use it in GitHub Desktop.
Script to log top 10 %mem processes
MAILTO=''
*/5 * * * * ~/ps.sh
# Log top 10 processes ordered by memory consumption
sudo ps -ax -o pid,%cpu,rss,user --sort=-rss | head -n11 | tail -n10 | sed "s/^/$(date '+%Y-%m-%d %H:%M:%S'): /" >> ps.log
# Limit log file size
tail -n1000 ps.log | sponge ps.log
@Bludwarf
Copy link
Author

Bludwarf commented Jul 8, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment