I'm using a ps
command as part of an exercise to identify processes running longer than a given threshold.
I'm using the following template to get the elapsed time for a know process command:
ps -eo etime,command | grep <something to identify a process> | grep -v grep | awk '{print $1}'
I notice with short-running processes, the etime (elapsed time) value takes the format minutes:seconds
and from this I can easily determine how long a process has been running.
For very long running processes (days long), I don't understand the format.
I have a MySQL server process that htop
shows as running for 126 hours.
Executing ps -eo etime,command | grep mysql | grep -v grep | awk '{print $1}'
gives me a value of 9-03:35:32
.
My best guess is that this means 9 something, 3 hours, 35 minutes, 32 seconds. I can't figure out what the units are for the 9.
The process in question has been running 126 hours, about 5.25 days. This suggests that the 9 in the above output does not represent days. They can't be half days either as (9 * 12) hours + 3 hours + 35 minutes + 32 seconds is less than 5 days.
How do I interpret the elapsed time value I am seeing for long-running processes? What units accompany the 9 in the above output?
ps
displays one or the other depending on the options you pass. – Gilles 'SO- stop being evil' Nov 01 '12 at 17:22etimes
instead ofetime
and compare the results. – Ruslan Jul 29 '18 at 19:34