ps filter for Chrome processes running longer than 10 minutes (600s):
ps -e -o pid,etimes,command | awk '{ if ( $2 > 600 && $3 ~ /chrome/) print $0 }'If the last print $0 is changed to print $1, it will just show the first column, the PID.
Copied from Nestor U. - https://unix.stackexchange.com/questions/531040/list-processes-that-have-been-running-more-than-2-hours/592472#592472
One liner to find processes that have been running for over 2 hours
ps -e -o pid,etimes,command | awk '{if($2>7200) print $0}'ps: process snapshot command
-e: list all processes
-o: include only specified columns
pid: process idetimes: elapsed time since the process was started, in seconds (note: some versions ofpsdo not supportetimes)command: command with all its arguments as a string
awk: pattern scanning and processing language
$2: second token from each line (default separator is any amount of whitespace)
7200: 7200 seconds = 2 hours
$0: the whole line in awk
Since the default action in the pattern { action } structure in awk is to print the current line, this can be shortened to:
ps -e -o pid,etimes,command | awk '$2 > 7200'See also: https://www.thegeekstuff.com/2010/02/awk-conditional-statements/