Find longest running non-root processes on a machine

ps -eo etime,pid,pcpu,ppid,args | sed -e '/\[.\+\]/d' -e '/^[ \t]*[0-9]\{2\}:[0-9]\{2\} /d' | sort -k1r
If you have ever been trying to look for a list of processes based on their elapsed time you don't need to look any further. This command lets you find the list of processes ordered in a reversed order (oldest at the top) that have been running for over an hour on your system. Any system processes are filtered out, leaving only user initiated ones in. I find it extremely useful for debugging and performance analysis.
Sample Output
   19:52:12  0.0  1815 qmgr -l -t fifo -u
   19:52:02  0.0  1815 tlsmgr -l -t unix -u -c
   19:50:43  0.0  2286 -bash
   15:40:27  0.0 39276 /usr/bin/perl /usr/local/bin/ master
   15:39:54  0.0 39391 /usr/bin/perl /usr/local/bin/
   15:39:39  2.5 39432 /usr/bin/perl /usr/local/bin/
   15:39:36  0.0 39454 /usr/bin/perl /usr/local/bin/

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: