Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
you might be able to check under the /proc/<pid> directory – rubixibuc Feb 25 '12 at 9:18
up vote 4 down vote accepted

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.

share|improve this answer
    
Thank You very much! I did not notice that in ps. – marioosh Feb 27 '12 at 9:39

You must log in to answer this question.

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