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

About ben.kevan

I am ben kevan.. Well yeah. .that's about it. More Posts

1 Comment to “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 comment

Your email address will not be published.

*