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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

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.