How to find out how long a process has been running (elapsed time)

local carpet cleaners . shuttle express . mary green . Ever wondered how long a process has been running? Did you know how to find it? Well, it’s actually quite simple and can be done with the following command:

ps aux | grep amarokapp | grep -v grep | ps -o etime `awk ‘{ print $2 }’`

Above gives: ps aux | grep amarokapp | grep -v grep | ps -o etime `awk ‘{ print $2 }’`ELAPSED25:22In the case you have multiple commands running with the grep’ed name, you may want to list a bit more information:

ps aux | grep amarok | grep -v grep | ps -o pid,etime,cmd `awk ‘{ print $2 }’`

Above gives: $ps aux | grep amarok | grep -v grep | ps -o pid,etime,cmd `awk ‘{ print $2 }’`PID ELAPSED CMD10825 24:00 amarokapp10840 23:54 ruby /opt/kde3/share/apps/amarok/scripts/score_default/score_default.rbRemember you can pick what options you want in ps.. to find the options run:

man ps

One thought on “How to find out how long a process has been running (elapsed time)”

  1. You can do it in even a simpler way by using pidof:
    > ps -o pid,etime,cmd `pidof amarok`
    PID ELAPSED CMD
    15569 03:24:57 /usr/bin/amarok

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>