Example 1: Identify all processes that have been running for more than 24 hours
The sort -etimes option will also sort them starting with the longest running process
# You can replace 24*3600 by the number of seconds, inside the if command ps -eo etimes,pid,lstart,etime,args --sort -etimes | awk '{if ($1 > 24*3600) print $0 }'
As you can see, I have not turned off my computer in days, so the longest running process started 6 days, 21 hours and 53 minutes ago…
Example 2: Identify all chrome that have been running for more than 5 minutes
# You can replace 5*60 by the number of seconds you want ps -eo etimes,pid,lstart,etime,args --sort -etimes | awk '/chrome/ {if ($1 > 5*60) print $0 }'
My output:
If you see processes that you wish to kill for some reason, once you have identified your process id (2nd column of the output), you can always do it with
# how to kill a process once you know their pid kill -9 YOUR_PID