Check How Long a Process is Running
How to check how long a process is running in Ubuntu? To check how long a process has been running in Ubuntu, you can use the ps
command with specific options. Here’s a step-by-step guide:
Open a terminal by pressing
Ctrl
+Alt
+T
or searching for “Terminal” in the application menu.To find the process you’re interested in, first run the
ps
command with theaux
options to get a list of all running processes, along with their details:
|
|
Look for the process in the output and note its process ID (PID), which is the second column in the output.
Now, run the
ps
command with the-p
option followed by the PID, and the-o
option to specify the output format:
|
|
Replace <PID>
with the process ID you noted in step 3. This command will show the elapsed time (ETime) for the specified process, which indicates how long the process has been running.
The elapsed time format is [[DD-]hh:]mm:ss
. If the process has been running for more than a day, it will show the number of days followed by a hyphen. If it has been running for more than an hour, it will show the number of hours followed by a colon. The minutes and seconds are always displayed.
For example, if the output is 02-10:30:45
, it means the process has been running for 2 days, 10 hours, 30 minutes, and 45 seconds.
Alternatively, you can use the htop
command to monitor processes and their runtime in real-time. If you don’t have htop
installed, you can install it using the following command:
|
|
Then, run htop
by typing the following command:
|
|
In the htop
interface, you can see the runtime of each process in the “TIME+” column.