#logs to a file with format
# seconds-since-epoch memory-used
# you can monitor the file with `tail -f $LOG` from another shell

LOG=log-name
CMDNAME=command-name
rm -f $LOG

while true; do                                                                                                                                         
mem=$(ps -C $CMDNAME --no-headers -o rss) && echo "$(date +%s) $mem" >> $LOG                                                                                                                                                                  
sleep 1
# uncomment to print memory usage live
# python analyze-memlog.py $LOG 
done