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

System Admin 0 Comments

How To Setup Nginx Server In Linux?

This post was last updated on August 1st, 2020 at 09:43 pmNginx, which is pronounced as ‘engine x’ is a free, opensource and high-performance HTTP server. It is among the

Linux Topics 0 Comments

How to Learn Linux Without Having a Linux Machine?

This post was last updated on November 3rd, 2020 at 05:36 pmWondering how to learn Linux without having a Linux PC with you?? Is it really possible or you’re just

System Admin 0 Comments

How to Make a Bootable USB

This post was last updated on October 15th, 2020 at 12:29 amIt seems that the 1.4MB floppy images are disappearing, so let’s make a boot image for usb from the

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply