I run a process that takes lot of time. Time is not a problem actually but I would like to know how much RAM memory it requires. Process is already running so /usr/bin/time is not an option. I found the pid of my process and run
watch -n 1 grep VmHWM /proc/3100/status
it works nice, I can leave it, do some other work, and just check later what was the value recorded with 1 seconds intervals. The problem starts if/when a process terminates (either finish job, or get killed because of OOM) because watch replace the last valid output with
grep: /proc/3100/status: No such file or directory
using option -e does not help. Is there a way to make watch not refresh output on non-zero exit? or show two most recent ones, so the previous zero exit can still be seen?
pgrepinto that. I'm not posting this as an answer as I don't have a Linux system to test properly on at the moment.pgrepto find process id. I don't understand howpgrepwould help me more, if process terminates then pgrep won't list it anyway, isn't?whileloop for this.while grep VmHWM /proc/3100/status; do sleep 1; done.watch -ecannot handle that in better way.