Check How Long a Process Has Been Running on Ubuntu with ps
Learn how to use the Linux ps command with the etime and etimes options to display the elapsed runtime of a specific process on an Ubuntu server, including finding the PID, formatting the output, and hiding headers for clean results.
Overview
This guide explains how to determine the runtime of a process on an Ubuntu (or any Linux) system using the ps command. It covers two formatting options— etime (human‑readable) and etimes (seconds)—and shows how to hide the column header.
Step 1: Locate the Process ID (PID)
Identify the PID of the target process. For example, to find the PID of openvpn: pidof openvpn The command returns a numeric PID, e.g., 6176.
Step 2: Query the Process Runtime
Use ps with the -p flag to specify the PID and the -o flag to select the desired output column.
Human‑readable format (days‑hours‑minutes‑seconds): ps -p 6176 -o etime Raw seconds since start: ps -p 6176 -o etimes Both commands will output the elapsed time for the process with PID 6176.
Optional: Hide the Header Line
Append an equals sign to the format specifier to suppress the column header:
ps -p 6176 -o etime= ps -p 6176 -o etimes=Example Output
Running ps -p 6176 -o etime might produce: 15:25 Running ps -p 6176 -o etimes would show the same duration in seconds.
Extended Information
You can request additional fields such as PID, command line, user ID, and group ID: ps -p 6176 -o pid,cmd,etime,uid,gid Sample output:
PID CMD ELAPSED UID GID
6176 /usr/sbin/openvpn --daemon 15:25 65534 65534This demonstrates how to replace the process name or PID with any other target you need to monitor.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
