How can I see the age (in seconds) of a process in Linux? I want to do it in a script. ps
has various start
/lstart
/start_time
options, which show a textual format for the date & time the process started. How can I get an integer representing the number of seconds elapsed since that start time?
Asked
Active
Viewed 252 times
0

Amandasaurus
- 31,471
- 65
- 192
- 253
1 Answers
0
suppose you want to know how many seconds have passed since the start of process 12345, then you execute
ps -p 12345 -o etimes=
For example:
$ date; ps -fp 2184; ps -fp 2184 -o etimes=
ma apr 20 20:00:38 CEST 2020
UID PID PPID C STIME TTY TIME CMD
root 2184 1 0 12:09 ? 00:00:00 /usr/sbin/apache2 -k start
28286
Apache was started 28286 seconds before I executed above commands.
PS. There is an old tool on unix systems, called "man".

Gerard H. Pille
- 2,569
- 1
- 13
- 11