Skip to content

Instantly share code, notes, and snippets.

@taoliu
Created January 6, 2012 21:15
Show Gist options
  • Save taoliu/1572440 to your computer and use it in GitHub Desktop.
Save taoliu/1572440 to your computer and use it in GitHub Desktop.
Monitor user time and memory usage of a process
#!/bin/bash
if [[ $# < 2 ]];then
echo 'need two parameters: $0 <interval> <pid>'
exit 1;
fi
INTERVAL=$1
PID=$2
echo " time rss"
while [ $(ps -p $PID|wc -l) -gt 1 ];do
ps -o time,rss -p $PID | tail -1
sleep $1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment