How to get the start time of a long running Linux Process?

LinuxOperating SystemOpen Source

Whenever we want to get an update about a specific process or different process we make use of the ps command which is short for “Process status” that tells us about the state of the current process and its characteristics and a whole lot more.

When clubbed with several flags and commands we can enhance the ps command to output the start time of different processes that are running on a particular Linux machine.

The command to print the time of long running processes in increasing order is shown below −

For Ubuntu and other Linux based Systems −

ps -eo pid , lstart , cmd

For Mac OS −

ps -eo pid , lstart , command

In the above command we are trying to make use of the process state utility provided by linux and then printing the process id, along with the lstart which will provide us the date+time started and then finally the command(name) of the process.


immukul@192 linux-questions-code % ps -eo pid,lstart,command
PID    STARTED                  COMMAND
 1   Fri Jun 25 23:14:44 2021 /sbin/launchd
56   Fri Jun 25 23:15:00 2021 /usr/sbin/syslogd
57   Fri Jun 25 23:15:00 2021 /usr/libexec/UserEventAgent (System)

It should be noted that the above command will print the output in the increasing order of the time and the most recent processes will be at the end of the output. In order to print the time in decreasing order we will need to make use of the sort command utility along with the above command. Consider the command shown below −

For Ubuntu and other Linux based Systems


ps -eo pid , cmd , etime | sort -n -k2

For Mac OS

ps -eo pid , command , etime | sort -n -k2


immukul@192 linux-questions-code % ps -eo pid,command,etime|sort -n -k2
 1 /sbin/launchd    08-13:56:50
56 /usr/sbin/syslog 08-13:56:34
57 /usr/libexec/Use 08-13:56:34
60 /System/Library/ 08-13:56:34
61 /System/Library/ 08-13:56:34
62 /System/Library/ 08-13:56:34
65 /usr/sbin/system 08-13:56:34
Published on 30-Jul-2021 08:36:04