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.

How do I find the uptime of a given linux process.

ps aux | grep gedit | grep -v grep

gives me a whole lot of information which includes the time at which the process was started. I am specifically looking for switch which returns the uptime of a process in milliseconds.


share|improve this question

2 Answers 2

up vote 5 down vote accepted
ps -o "cputime=" $pid

See "Standard format specifiers" in the ps manual page.

(The = character in -o causes the header to be disabled.)

share|improve this answer
Is this correct? The man page makes it sound like it's measuring how long the process has spent in the cpu (actively sending commands), not how long it has been running (counting idle times, etc). –  tjameson Jul 9 '12 at 20:18
I can confirm that this is a wrong answer. –  Gandaro Apr 24 at 0:08
The correct answer is the one from Abdull –  Xavi Montero May 17 at 10:31
This just returns 00:00:00 for all my processes. –  NobleUplift Aug 27 at 16:14

As "uptime" has several meanings, here is a useful command.

ps -eo pid,comm,lstart,etime,time,args

This command lists all processes with several different time-related columns. It has the following columns:

PID COMMAND                          STARTED     ELAPSED     TIME COMMAND

PID = Process ID
first COMMAND = only the command name without options and without arguments
STARTED = the absolute time the process was started
ELAPSED = elapsed time since the process was started (wall clock time), format [[dd-]hh:]mm:ss TIME = cumulative CPU time, "[dd-]hh:mm:ss" format
second COMMAND = again the command, this time with all its provided options and arguments

share|improve this answer

Your Answer


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.