Linux how long a process has been running?

To see how long a process has been running on a Linux system, you can use the ps command with the -o and etime options.

For example, to see the elapsed time for the process with PID 12345, run the following command:

ps -o etime= -p 12345

The etime option displays the elapsed time since the process was started, in the format dd-hh:mm:ss.

If you want to see the elapsed time for all processes on the system, you can run the following command:

ps -eo etime,pid,comm | sort

This command will display the elapsed time, PID, and command name for all processes, sorted by elapsed time.

Note: The ps command is a versatile tool that provides a lot of information about processes running on the system. The options used in these examples are just a few of the many available. To learn more about the ps command, refer to the man page or the online documentation.

Leave a Comment