Home Linux Commandline Tools How to Find Uptime of Particular Linux Process

How to Find Uptime of Particular Linux Process

Along with the system uptime, it’s also possible in the Linux operating system to check the uptime of a particular Linux process or service. Various Linux tools are available that can be used to quickly know how long an individual process has been running in Linux.

In this article, I’ll help you to know not just the various methods to find the uptime of a Linux system but also list all running processes and uptime of a particular Linux process, which you can apply on all Linux-based operating systems.

How to Find Uptime of Your Linux System

There are three most basic commands available that you can refer to check the time of your last system reboot: uptime, w, and top.

1. Check Linux Running Time Using Uptime Command

By just typing ‘uptime‘ in the terminal, it will display a result in one line.

$ uptime

Here, as you move from left to right, the line shows the current time, the number of hours and minutes your Linux system has been running, the number of current users logged in, and the load average of a system for the past 1, 5, and 15 minutes.

If you want results in another format with particular information, you can use various options available with the uptime command. For instance, using the -p option displays only the time up to which the Linux system is up and running.

$ uptime -p
Check Linux Uptime
Check Linux Uptime

2. Check Linux Uptime Using W Command

Similar to uptime, the w command also displays the same uptime pieces of information along with users logged on and what they are doing.

$ w
Show Linux Uptime and All Logged-in Users
Show Linux Uptime and All Logged-in Users

3. Check Linux Uptime Using Top Command

Being one of the most popular Linux tools for process management, the top command also shows how long you have been logged on to the system.

Furthermore, it goes beyond presenting a table containing a list of all running services on a system with their various information like CPU and memory usage.

$ top
Show Uptime and Running Processes
Show Uptime and Running Processes

How to Display Running Processes in Linux

If you don’t know there are no particular Linux tools that can directly give you the uptime of a particular service. You first need a command that can list currently running processes and combine that with another command (usually grep command) to identify the individual processes and their uptime.

That’s why before we head toward finding the uptime of a particular Linux service, let’s also see how we can list running processes in Linux using various methods.

1. List Running Linux Processes Using top Command

As you saw above, along with the uptime of the Linux system, the top command also displays the list of running processes in order of decreasing CPU usage by just executing:

$ top
List Linux Running Processes
List Linux Running Processes

Each column of the output in a tabular form lists particular information like the first column PID displays process IDs of services.

2. Show Linux Processes Using ps Command

The ps (processes status) command also lists currently active running processes. However, unlike the top, it presents only a snapshot of a process as a static list instead of real-time data.

$ ps

Using various options along with the ps command will give detailed information. For instance, running the below command displays a list of all processes on the system with process ids, CPU, and memory usage.

$ ps aux
Show Linux Running Processes
Show Linux Running Processes

3. View Linux Processes Using htop and atop Commands

Apart from the pre-installed top and ps commands, you can also employ other tools like htop and atop that offers the same output but in an easy-to-understand and user-friendly way.

To install htop and atop on your Linux system, use the respective package managers as shown.

Install Htop in Linux
$ sudo apt install htop        [On Debian, Ubuntu and Mint]
$ sudo yum install htop        [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a htop          [On Gentoo Linux]
$ sudo apk add htop            [On Alpine Linux]
$ sudo pacman -S htop          [On Arch Linux]
$ sudo zypper install htop     [On OpenSUSE]    
Install atop in Linux
$ sudo apt install atop        [On Debian, Ubuntu and Mint]
$ sudo yum install atop        [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a atop          [On Gentoo Linux]
$ sudo apk add atop            [On Alpine Linux]
$ sudo pacman -S atop          [On Arch Linux]
$ sudo zypper install atop     [On OpenSUSE]    

Now, just type the htop or atop commands and you’ll see a piece of real-time detailed information.

$ htop
$ atop
View Linux Running Processes
View Linux Running Processes

If you want to explore more about the commands, check out its man pages by running the command:

$ man htop
$ man atop

How to Find Individual Process Uptime in Linux

Till now, you learned how to get system uptime and a list of all currently running processes. It’s time to get the uptime of a particular running process.

1. Find Particular Process Uptime Using Ps Command

As you saw above, ps provides a snapshot of active processes on the system, we will pipe this output to identify particular processes using a grep (global regular expression print) utility and add some options that will give the desired output.

To do so, execute the below command in your Linux terminal:

$ ps -eo pid,lstart,,etime,cmd | grep -i bash
OR 
$ ps -eo pid,lstart,,etimes,cmd | grep -i bash
Find Particular Process Uptime in Linux
Find Particular Process Uptime in Linux

Here, etime is the elapsed time since service was started, in the form of [[DD-]hh:]mm:ss and etimes also the same with a difference in results in seconds. If you find it difficult to run the above command, you can make use of an alias to shorten it for regular use.

Instead of the application name, you can also give the process id that you can get from the output list of active processes.

2. Find Specific Process Uptime Using Monit

Though you may first need to install it, Monit is yet another small utility for managing and monitoring processes, files, and filesystems on a Unix system along with automatic maintenance and repair.

Install Monit on Linux
$ sudo apt install monit         [On Debian, Ubuntu and Mint]
$ sudo yum install monit         [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a monit           [On Gentoo Linux]
$ sudo apk add monit             [On Alpine Linux]
$ sudo pacman -S monit           [On Arch Linux]
$ sudo zypper install monit      [On OpenSUSE]    

Once installed, you also need to configure Monit in Linux before you start using it for process uptime. First, launch the monit daemon and check the status by running:

$ sudo monit
$ sudo systemctl status monit
Check Monit Status
Check Monit Status

Surprisingly, Monit also provides a web interface for those who prefer a graphical interface instead of a command line. So, to enable the web interface, you need to edit the monit configuration file located mainly at /etc/monit/monitrc for Debian-based Ubuntu and Linux Mint and at /etc/monit.conf for Red-Hat-based Fedora.

Just open the file in your favorite editor:

$ vi /etc/monit/monitrc

And uncomment the following lines shown below screenshot i.e. IP address and monit admin user.

Configure Monit in Linux
Configure Monit in Linux

Next, you also need to restart the monit service to apply your new config changes. Enable it also if you want to auto-run during system startup.

$ systemctl start monit
$ systemctl enable monit
$ systemctl status monit

Now, you’re ready to access the monit web interface by navigating to the localhost URL in your browser.

https://localhost:2812

As you will hit the url, it will prompt you for credentials. You can use the default “admin” as username and “monit” as password. Once entered, you’ll see the below screen.

Monit Service Manager
Monit Service Manager

The interface will list all running processes along with other details like CPU, memory usage, boot time, and uptime.

Check Linux System Status
Check Linux System Status

At last, we learned to check the uptime of individual processes in Linux, but before we also need its process ID which we saw how we can get using various Linux command line tools. You can explore more above all methods to get the best-desired output in your comfortable way.

Sarvottam
Sarvottam Kumar is a software engineer by profession with interest and experience in Blockchain, Angular, React and Flutter. He loves to explore the nuts and bolts of Linux and share his experience and insights of Linux and open-source on the web/various prestigious portals.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.