[lug] /usr/bin/time: memory stats?

Davide Del Vento davide.del.vento at gmail.com
Sun Mar 14 16:03:58 MDT 2010


> I'm interested in getting memory use statistics on various apps.
> Top can do it, but I need it in a shell script like this:
>
> /usr/bin/time -f "cpuTime: %S  elapTime: %e  avgK: %K  \
>  maxRes: %M avgRes: %t " someCommand ...
>
> But at least on my system (Debian 5.0.4, Linux 2.6.26-2-686)
> all the memory use statistics are always 0.  Am I missing
> some feature to enable them?
>
> Sample output:
> cpuTime: 0.11  elapTime: 2.46  avgK: 0  maxRes: 0  avgRes: 0

I think that the only way to do this in Linux is throught /proc
Things like POSIX getrusage never worked, in my experience, and always
return 0 (not sure if that's the case here).
Tomorrow I can send you a script that I wrote for your very same
purpose (basically the linux "traslation" of a C program which on
other UNIX'es was based on the syscall getrusage). But it wasn't a big
deal to write, so you may want to do that yourself and have fun :-)
Bye,
;Dav



More information about the LUG mailing list