How to Check How Long a Process Has Been Running in Linux

Linux, with its powerful command-line interface, provides users with a myriad of tools to monitor and manage processes efficiently.

One essential piece of information for troubleshooting or system optimization is knowing how long a process has been running.

In this article, we’ll explore simple commands that new Linux users can use to check the duration of a running process.

1. ps Command

The ps command is a fundamental tool for viewing information about processes on a Linux system.

To find out how long a process (program or application) has been running, open a terminal and type the following command:

ps -eo pid,comm,etime
List Process Running Time in Linux
List Process Running Time in Linux

This command lists the process ID (PID), command name, and elapsed time (etime) for all processes. The elapsed time column displays the time duration in the format “dd-hh:mm:ss“, where “dd” represents days, “hh” represents hours, “mm” represents minutes, and “ss” represents seconds.

For a more targeted approach, you can combine the `ps` command with the grep command to filter out information about a specific process.

ps -eo pid,comm,etime | grep "process_name"

This command narrows down the output to only display information about the specified process, making it easier to determine how long it has been running.

Get Process Running Time in Linux
Get Process Running Time in Linux

2. top Command

For a more user-friendly and interactive process monitoring experience, you can use the top command, which is used to provide a real-time overview of all running processes along with various details like CPU usage, memory usage, and running time.

top

After running the top command, just press 'c' to toggle between different display options and locate the desired process, and its uptime will be displayed in the "TIME+" column, which represents the total accumulated CPU time for each process.

Check Process Running Time in Linux
Check Process Running Time in Linux

3. System Monitor GUI Tool

Linux also offers graphical user interfaces (GUIs) for those who prefer a visual representation of system information. The GNOME System Monitor is a popular choice for many Linux distributions.

To install the GNOME System Monitor on a Linux system, you can use the package manager specific to your Linux distribution.

sudo apt install gnome-system-monitor         [On Debian, Ubuntu and Mint]
sudo yum install gnome-system-monitor         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/gnome-system-monitor  [On Gentoo Linux]
sudo apk add gnome-system-monitor             [On Alpine Linux]
sudo pacman -S gnome-system-monitor           [On Arch Linux]
sudo zypper install gnome-system-monitor      [On OpenSUSE]    
sudo pkg install gnome-system-monitor         [On FreeBSD]

Once installed, you can launch it from the application menu or by running:

gnome-system-monitor

Navigate to the “Processes” tab, find your desired process, and check the “CPU Time” column, which will display the total CPU time consumed by a process, offering a quick glance at its running duration.

Find Process Running Time in Linux
Find Process Running Time in Linux
Conclusion

Understanding how long a Linux process has been running is a crucial skill for both troubleshooting and optimizing system performance. With these simple commands, new Linux users can easily retrieve information about process duration, gaining valuable insights into their system’s activity.

Whether using basic commands like ‘ps‘ or ‘top‘ and GUI options like GNOME System Monitor, Linux provides a variety of tools to meet the diverse needs of its users.

As you continue your Linux journey, mastering these commands will empower you to efficiently manage and monitor processes on your system.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

Ravi Saive
Ravi Saive
Administrator
About the author

I'm Ravi Saive, an award-winning entrepreneur and founder of several successful 5-figure online businesses, including TecMint.com, GeeksMint.com, UbuntuMint.com, and the premium learning hub Pro.Tecmint.com.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.