Find memory usage along with time

Hi Guys,

I have a script. It calls an executable inside (programmed in C). I will have to find the execution time of that script and amount of memory consumed by that process as well.

#!/bin/sh

echo "Script starting"

echo "executable staring"
executable parm1 parm2 parm3
echo "executable completed"

echo "Script completed"

exit

I know time ./script.sh will give me the execution time of this. What I would want to know is the total memory(RAM) and %CPU utilized by this as well.

System Details:
HP-UX
B.11.23

Capture the PID of your executable, then use ps to check CPU & MEM:

UNIX95=1 ps -ef -o pid,pcpu,vsz,comm | grep <PID>

-o Not recognized...!!! :frowning: :frowning:

Yes, -o is an illegal option when you simply run ps on HP-UX.

So you have to set UNIX95 variable to use the XPG4 environment instead of the HP-UX environment.

$ UNIX95=1 ps -ef -o pid,pcpu,vsz,comm | grep init
    1  0.40     852 init
   23  0.05       0 pagetableinit_daemon
$ uname
HP-UX

Thanks, Yoda :slight_smile:

pid -- process id
pcpu -- CPU utility%
vsz -- memory usage? in KB or MB?
comm -- command