How to check elapsed time in Terminal

Please follow and like us:

When we have processes running for a while and we want to know how long they have been running, there are a few nifty ways we can check them on Mac and Linux/Unix. Here is one such method to check elapsed time in BASH.

First grab the process ID (PID) using the following command. In the following command, we are trying to grab the process ID of mongoDB.

pgrep mongo

pgrep command tells shell prompt on Mac/Linux/Unix terminal to capture the process ID (PID) of the process we are interested. In this case it is mongoDB.

In the next command we will find out the execution time.

ps -p PID -o etime

Here PID is the process ID we got from the earlier command. So replace it with your own actual PID that you got from the pgrep command.

ps: command to call process status
-p: option is used to display information for a particular PID
PID: the specified PID
-o: give output for PID with the following keywords. Multiple can be specified with a comma
etime: elapsed time
There are many other options that can be utilize like nice, start, stime etc. Try them with a comma separated like below:

ps -p PID -o etime, start

Here is an example of MongoDB process ID that we ran on our Terminal.

pid-mongo.pngThat’s it! Try it.


Techie by day, blogger by night. Love the outdoors, enjoy traveling and building new and interesting things. Follow me if you want to know something.
Please follow and like us:

Leave a Reply