How To Check The Running Time Of A Process In Linux/Unix ?

How To Check The Running Time Of A Process In Linux/Unix ?

 

This post was last updated on August 1st, 2020 at 10:13 am

In Unix like operating systems, a process is a program in execution. The running time of a process means how long a process has been running on a system. There are different ways to determine the running time of processes in the Linux or Unix system for example by using an etime option with ps command. So let us find the running time of a process.

Process Identifier(PID)

There can be multiple processes running in a system. Kernel identifies each process with a unique id called process id or PID. To find the PID of a process first open your terminal and then execute the following command –

pidof process_name

For example to find the PID of Rhythmbox use –

pidof Rhythmbox

Now you can see the PID of Rhythmbox which is 2423. We need to find the PID of a process in order to find the running time using the ps command as given in the coming section.

Display the running time using ps command

The ps (process status) command displays information about a selection of active/running processes. We will use the following two options to display running time –

etime – It displays elapsed time since the process was started, in [[DD-]hh:]mm:ss format.

etimes– It displays elapsed time since the process was started in seconds

Find running time using etime option

To display the running time use the following command in your terminal –

ps -p PID -o etime

For example to display the running time of the process with PID 2423, use –

ps -p 2423 -o etime

Find running time using etimes option

To display the running time use the following command in your terminal, this will display the running time in seconds –

ps -p PID -o etimes

For example to display the running time of process with PID 2423, use –

ps -p 2423 -o etimes

Conclusion

In this article, you learned to find the PID and then use it to determine how long a process has been running in a system. If you want to know more about ps command then see its manual page by using man ps.

Now if you want to know more about the usage of ps command you can read how to check the status of active processes using ps command.

Previous [ubuntu] issuing seeing Ubuntu desktop
Next How To Install And Use Nano Text Editor In FreeBSD?
 

About author

You might also like

How To 0 Comments

How To Upgrade To Ubuntu 20.04 LTS From Ubuntu 18.04 Or Ubuntu 19.10?

This post was last updated on August 1st, 2020 at 12:30 pmUbuntu comes in two releases the first one is LTS and the second is standard versions. LTS (Long Term

Linux Topics 0 Comments

How To Backup And Restore Ubuntu Using Timeshift?

This post was last updated on August 1st, 2020 at 02:53 pmA system backup is a process in which the state, files, and data of a computer system are copied

Linux Topics 0 Comments

How To Use Vi Text Editor An Easy Guide

This post was last updated on August 3rd, 2020 at 03:13 pmContents1 Introduction to vi2 Starting vi in your terminal3 Vi Operating modes4 Moving cursor around text5 Entering, modifying and

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply