Skip to content

Instantly share code, notes, and snippets.

@scottstensland
Last active August 18, 2022 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottstensland/d882d1acd94bb67d969df8f17c6e0e0f to your computer and use it in GitHub Desktop.
Save scottstensland/d882d1acd94bb67d969df8f17c6e0e0f to your computer and use it in GitHub Desktop.
issue process list to show top cpu and ram usage
#!/bin/bash
# ... issue process list to show top cpu and ram usage
# usage :
#
# show_cpu_and_memory_usage.sh >> /file/holding/usage.log
SLEEP_PERIOD=5
output_header=$( ps aux|head -1 )
while true; do
curr_snapshot=$( ps aux | sort -nrk 3,3 | cut -c1-155 | head -n 20 )
echo
date '+%Y%m%d_%H%M%S'
echo
echo "$output_header"
echo "$curr_snapshot"
sleep $SLEEP_PERIOD
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment