In the Linux system, a number of processes must stay running all the time that ensures the system is up and working perfectly. We all know that Linux offers the most control over your system. Why not find out how long a process is running?
Well, no surprise. Linux allows doing that without the necessity of any additional package. In fact, the following tutorial is usable by almost any Linux user (unless your system is missing the core components).
Let’s find out.
Determining running time
In the regard, the “ps” command is the first choice. Most of the Linux CLI users are familiar with the standard UNIX or BSD notation when it comes to specifying the “ps” options.
If you want to get the UNIX notation, run the following command –
In the command output, the “STIME” column indicates the starting time of the process. From the above output, it’s clear that “bash” started at 23:02 (24-hr format). However, it doesn’t indicate the date.
According to the man page of “ps”,
Note – For usage convenience, the man page was extracted to a text file. Learn how to export Linux command outputs to a file.
Need to get the result with the BSD notation? Then use the following command –
In the output, the “Start” column reveals the start date only if the process is older than the current date.
It’s also possible to tell “ps” to show the elapsed time in the output.
ps -eo pid,cmd,etime
This command specifies 3 different fields – the PID of the process, the command for running the process and the elapsed time respectively.
For the BSD notation, use the following command –
ps axo pid,cmd,etime