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

Whenever we want to get an update about a specific process or different processes, we make use of the ps command which is short for "Process Status". This command tells us about the state of current processes, their characteristics, and much more.

When combined with several flags and options, we can enhance the ps command to output the start time of different processes running on a Linux machine. This is particularly useful for monitoring long-running processes and system diagnostics.

Basic Commands to Display Process Start Time

The command to print the start time of processes varies slightly between different systems −

For Ubuntu and Linux-based Systems

ps -eo pid,lstart,cmd

For macOS

ps -eo pid,lstart,command

In these commands, we use the process status utility with the following options −

  • -e − Select all processes

  • -o − Specify output format

  • pid − Process ID

  • lstart − Full date and time when the process started

  • cmd/command − Command name or full command line

Sample Output

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)

Displaying Elapsed Time

To show how long processes have been running, use the etime field which displays elapsed time in the format [DD-]HH:MM:SS

For Ubuntu and Linux-based Systems

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

For macOS

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

Sample Output with Elapsed Time

PID COMMAND          ELAPSED
  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

Additional Useful Options

Option Description Example Output Format
lstart Full start date and time Fri Jun 25 23:14:44 2021
stime Start time (time only) 23:14
etime Elapsed time since start 08-13:56:50
etimes Elapsed time in seconds 723410

Filtering Specific Processes

To check the start time of a specific process, combine ps with grep

ps -eo pid,lstart,cmd | grep process_name

Conclusion

The ps command with appropriate flags provides comprehensive information about process start times and running duration. Using lstart shows the exact start date and time, while etime displays how long processes have been running. These commands are essential for system monitoring and troubleshooting long-running processes.

Updated on: 2026-03-17T09:01:38+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements