Skip to Content

Check Process running time in Ubuntu

In this blog post, we will discuss two different ways to check the running time of a process in Ubuntu. It is useful for troubleshooting and determining how long specific processes are taking to run. We will also discuss some of the benefits of each method. Let’s get started!

Check process running time with ps command in Ubuntu

The best way to check process running time in Ubuntu is using ps command. Open the terminal and type ps -p pid -o etime,etimes. It will list the process running time.

The ps command can be used to view information about all running processes. To use this command, simply type “ps aux” into your terminal. You will then see a list of all running processes, as well as their PID (process ID).

You need to pass the -o etimes or -o etime to the ps command. The syntax is:

  • ps -p {PID-HERE} -o etime
  • ps -p {PID-HERE} -o etimes

Here,

  • etime Display elapsed time since the process was started, in the form [[DD-]hh:]mm:ss.
  • etimes Display elapsed time since the process was started, in seconds.

Let us find and print the PID creation date. In other words find out when the process was started on Ubuntu, enter:

  • $ sudo ps -p {PID} -o start,etimes,etime
  • $ sudo ps -p {PID} -o start,etimes,etime
  • $ sudo ps -p {PID} -o pid,cmd,start,etimes,etime
  • $ sudo ps -C {process-name} -o pid,cmd,start,etimes,etime

Check process running time from /proc filesystem in Ubuntu

The /proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information.

It’s sometimes referred to as a process information pseudo-file system. It doesn’t contain ‘real’ files but run time system information (e.g. system memory, devices mounted, hardware configuration, etc).

# ls -ld /proc/16337
dr-xr-xr-x. 9 root root 0 Aug 5 17:20 /proc/16337/

Try out both methods and see which one works best for you!

We hope this blog post has been helpful. If you have any questions or comments, please feel free to reach out to us! We would be happy to help.