How Long Has a Process Been Running Linux
If you want to know how long has a process been running linux, the quickest answer is to check the process’s elapsed time with ps. For a known PID, ps -p <PID> -o etime= shows how long the process has been alive, while ps -p <PID> -o lstart= shows the exact start time.
Quick answer: the fastest way to check process runtime
Use ps when you already know the process ID:
ps -p 1234 -o pid=,etime=,lstart=,cmd=This prints the PID, elapsed time, start time, and command. For example, the elapsed time might look like 02:14:37, which means the process has been running for 2 hours, 14 minutes, and 37 seconds.
If you only want the elapsed time:
ps -p 1234 -o etime=How to check process runtime with ps
ps is usually the most reliable and readable option for checking process age. The key field is etime, which means elapsed time since the process started.
Useful ps formats
etime, elapsed time since startlstart, full start date and timeetimes, elapsed time in total secondscmd, the command line that launched the process
Example with seconds, which is easier for scripts:
ps -p 1234 -o etimes=Example for a process name, when you do not know the PID yet:
ps -C nginx -o pid=,etime=,cmd=If multiple processes match the same name, ps will list them separately, which is often helpful when a service has several worker processes.
How to find a process by name before checking runtime
Many users know the program name but not the PID. In that case, find the PID first, then inspect the runtime.
pgrep -a nginxThat shows matching PIDs and command lines. Then you can run:
ps -p <PID> -o pid=,etime=,lstart=,cmd=You can also combine both ideas in one command if the process name is specific enough:
ps -C sshd -o pid=,etime=,lstart=,cmd=How to check a process start time
Elapsed time tells you how long the process has been running. Start time tells you when it began.
ps -p 1234 -o lstart=This is useful when you need an exact timestamp instead of a duration. For example, a process may have been running for 3 days, but the start time tells you precisely when it launched.
Reading the output
lstart usually includes the weekday, month, day, time, and year. That makes it easier to confirm whether a process started recently or has been running since a previous reboot.
Using top or htop
top and htop are better for live monitoring than for precise inspection, but they can still help.
top
In top, the process list includes a TIME+ column. That column does not mean wall-clock runtime. It shows cumulative CPU time used by the process.
If you need elapsed runtime, top is less direct than ps. It is useful for seeing which process is active, but not for answering how long it has existed.
htop
htop can display columns such as start time or processor time depending on your configuration. If your version includes a start-time column, it can help visually, but the exact column set varies by system and user settings.
For a dependable answer, use ps rather than relying on display defaults in top or htop.
Elapsed time versus CPU time
| Type | What it means | Example | Best command |
|---|---|---|---|
| Elapsed time | How long the process has existed since it started | 2 hours, 14 minutes | ps -p 1234 -o etime= |
| Start time | The exact date and time the process began | Mon Nov 1 09:12:34 2026 | ps -p 1234 -o lstart= |
| CPU time | How much processor time the process has used | 00:03:18 | top, ps -p 1234 -o time= |
This distinction matters. A process can run for days but use only a few minutes of CPU time if it mostly waits for input, network traffic, or disk activity.
Using /proc for a lower-level check
Advanced users can read process information directly from the proc filesystem. The file /proc/<PID>/stat contains the process start time in kernel ticks, but it is not human-friendly and needs conversion against system uptime.
For most cases, ps is simpler and less error-prone. Use /proc only if you need raw process data or are writing a script that parses system internals.
Common mistakes
- Confusing CPU time with runtime,
TIMEin some tools means CPU usage, not elapsed time. - Using the wrong PID, process IDs can change after a restart.
- Ignoring multiple matches, a service name may refer to several worker processes.
- Assuming output format is identical everywhere, some tools and versions display fields slightly differently.
- Expecting access to every process, non-root users may see limited details for processes owned by other users, depending on system settings.
Permissions and access limits
On many Linux systems, you can inspect your own processes without any special privileges. Viewing details for another user’s processes may be limited, especially on hardened systems or containers with restricted proc access.
If a command shows less information than expected, try the same query with your own process first, or use sudo if you have permission and need full details.
Practical examples
Check a single PID
ps -p 4321 -o pid=,etime=,lstart=,cmd=This is the best choice when a monitoring tool, log file, or system report already gave you the PID.
Check all matching processes by name
ps -C apache2 -o pid=,etime=,lstart=,cmd=This helps when a service has multiple child processes and you want to compare their ages.
Get just the runtime in seconds
ps -p 4321 -o etimes=This is especially useful in shell scripts or automation, where numeric output is easier to compare.
How to read elapsed time output
ps formats etime in a readable style. Short runtimes may look like MM:SS, while longer runtimes may look like HH:MM:SS or include days, such as 3-04:12:08.
00:45, 45 seconds12:08, 12 minutes, 8 seconds02:14:37, 2 hours, 14 minutes, 37 seconds3-04:12:08, 3 days, 4 hours, 12 minutes, 8 seconds
If you need machine-readable output, use etimes instead of etime.
Frequently Asked Questions About how long has a process been running linux
How do I check how long a process has been running in Linux?
Use ps -p <PID> -o etime=. It shows the elapsed time since the process started.
What is the ps command to show process elapsed time?
ps -p <PID> -o etime= is the simplest command. Use etimes if you need total seconds instead of formatted output.
How do I find the start time of a Linux process?
Run ps -p <PID> -o lstart=. That shows the exact start timestamp rather than the elapsed duration.
What is the difference between elapsed time and CPU time?
Elapsed time is how long the process has existed. CPU time is how much processor time it has actually used. A sleeping process can have a long elapsed time and a small CPU time.
Can I check process runtime without root?
Yes, often you can check your own processes without root. Viewing other users’ processes may be limited unless you have the right permissions.
Why does top show a different time than ps?
top often shows CPU usage time, not elapsed runtime. ps with etime is the better command when you want to know how long a process has been running.
Conclusion
The most reliable way to answer how long has a process been running linux is to use ps and check etime. If you need the exact launch moment, use lstart. If you only remember the process name, find the PID first, then inspect the process. For scripts, etimes is often the easiest format to work with, while top and htop are better for live monitoring than for exact runtime checks.
