Last Updated on
Insight: Tutorial To Check How Long a Process Has Been Running in Linux
If you want to know how long a process has been running in Linux then this post is for you as we are going to show you the multiple way to check how long a process has been running in Linux.
Check How Long a Process Has Been Running in Linux
We will be using ps command to see the duration of process in Linux. ps or processes status displays the information about the active/running processes on the Linux system. We will use etime or etimes option to figure out the duration of the process.
Let’s start with by finding out the PID of a process. Run the following command to find out the PID of a process.
sudi pidof httpd 30446 30330 30333 30423 30441 16007
Now, we will use pid command to find out the duration of the process.
Use the ps command with
etime option to get detailed elapsed time.
sudo ps -p 16007 -o etime ELAPSED 15-01:15:22
It says that process has been running since 15 days, 1 hour, 15 minutes and 22 seconds.
You can also use process name instead of Process ID (PID). Run the following command by using process namel
sudo ps -eo pid,etime,cmd | grep httpd | grep -v grep
You can also use etimes option which will show you the elapsed time in total seconds.
sudo ps -p 16007 -o etimes ELAPSED 1230950
You can also use lstart option from the ps Command. It shows an exact minutes of the process start.
sudo ps -p 16337 -o lstart STARTED Mon Sep 02 16:30:11 2019