Created
March 1, 2011 08:43
-
-
Save msiebuhr/848832 to your computer and use it in GitHub Desktop.
Starts a process and log it's memory use while it's running.
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 | |
# Measure the memory usage of process with PID | |
# Execute whatever's given on the command-line | |
$* > /dev/null & | |
sleep 1 | |
# Monitor it | |
PID=$! | |
FILENAME=${1}_${PID}_`date --iso`.txt | |
ITERATION=1 | |
STATUS_FILE=/proc/${PID}/status | |
if [[ -e $STATUS_FILE ]]; then | |
echo RUNNING! | |
echo -n > $FILENAME | |
fi | |
while [[ -e $STATUS_FILE ]]; do | |
VmSize=`awk '/VmSize/ {print $2}' $STATUS_FILE` | |
echo $ITERATION $VmSize >> $FILENAME | |
echo -n . | |
let ITERATION++ | |
sleep 10 | |
done | |
kill -9 $PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment