Reputation: 741
I want to find the process id using netstat and see how long this process has been running by using ps. I currently have two separate commands to do this. How do I do it with one command?
netstat -anp | grep http | grep ESTABLISHED | awk {'print $7}' | awk -F '/' {'print $1'}
and:
ps -eo pid,uid,ruser,etime | grep someuser
Upvotes: 5
Views: 25575
Reputation: 3880
for i in `netstat -anp | grep http | grep ESTABLISHED | awk {'print $7}' | awk -F '/' {'print $1'} | uniq` ; do ps -eo pid,uid,ruser,etime | grep $i ; done
Upvotes: 14