Monitoring memory use
    Ben Scott 
    dragonhawk at gmail.com
       
    Fri Sep 21 09:55:45 EDT 2007
    
    
  
On 9/21/07, Alex Hewitt <hewitt_tech at comcast.net> wrote:
> One simple way 'ps aux | grep myjob'
  A slightly improved version might be:
ps -C myjob -o pid,start,time,vsz,rss,cmd
  In the above, "myjob" has to be the actual executable file name.
Sometimes that's not what you might expect; it depends on how the job
is invoked.  But the advantage of using "-C" is that it won't find
anything else; the "grep" method has a tendency to pick up other
processes (including the grep itself).
  The "-o" business just selects the output fields.  PID, wall clock
start time, CPU time used, virtual segment size, resident set size,
and command are the ones I expect might be useful for this.  See "man
ps" for all the possible fields (lots!).
  Then run that as a parallel cron job that starts at the same time
and logs the process periodically.  For example, in your crontab:
# run "myjob" every night at 2:00 AM
00 02 * * * $HOME/bin/myjob
# monitor myjob for from 2 AM to 2:30 AM, every two minutes
0-30/2 02 * * * ps --no-header -C myjob -o pid,start,time,vsz,rss,cmd
> $HOME/myjob.pslog
  (Note: Syntax in the above not checked.  Testing is advised.)
-- Ben
    
    
More information about the gnhlug-discuss
mailing list