6

Is a way to check how long a proccess X is running or when it was started ? The first thought occurred to me was ps command, but found nothing.

1
  • you might be able to check under the /proc/<pid> directory
    – rubixibuc
    Feb 25, 2012 at 9:18

1 Answer 1

5

The simplest way is ps -ef, look at the STIME column for when it was started. For a process X, use ps -ef | grep -i X. A more complicated method (and necessary for elapsed time) would be to use the -o option. Using that:

The equivalent of ps -ef is ps -eo uid,pid,ppid,c,stime,tty,time,cmd

From the man page:

  etime      ELAPSED elapsed time since the process was started, in the
                     form [[DD-]hh:]mm:ss.

  start      STARTED time the command started. If the process was started
                     less than 24 hours ago, the output format is
                     "HH:MM:SS", else it is "  <mm dd" (where Mmm is a
                     three-letter month name). See also lstart, bsdstart,
                     start_time, and stime.

So a simple one for a process named "X" would be:

Searching commands run: ps -eo pid,cmd,start,etime | grep -i X
Searching executable names: ps -eo pid,comm,start,etime | grep -i X
Searching both: ps -eo pid,comm,cmd,start,etime | grep -i X

You may want to set up an alias, if you're going to be using it a lot.

2
  • Thank You very much! I did not notice that in ps.
    – marioosh
    Feb 27, 2012 at 9:39
  • Is there a way in which I could get the etime in seconds? Feb 20, 2017 at 20:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .