View Full Version : Bash script question

July 25th, 2011, 12:34 PM
what I tried to do is make a script that prints the id of the longest running process with a particular label, what I came up with is :


ps -elfo pid,etime | grep "$1$" | sort -r -k 2,2 | head -n 1 | awk '{print $1;}'

but (perhaps unsurprisingly) it does nothing... can anyone give me some advice here?


July 25th, 2011, 02:19 PM
ps -elfo pid,etime
ERROR: Conflicting format options.

your first step fails, try
ps efo pid,etime

July 25th, 2011, 03:57 PM
It's always going to be 'init' (1).