Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.