Pages

Friday, October 3, 2014

Print out which hosts are running some process

$ for i in `cat hosts_list`; do RES=`ssh myusername@${i} "ps -ef " |awk '/[p]rocessname/ {print $2}'`; test "x${RES}" = "x" && echo $i; done

Given a hosts list, ssh one by one and echo its name only if 'processname' is found running.




commandlinefu.com


by David Winterbottom (codeinthehole.com)






from All commands http://ift.tt/1rEKEkw

No comments:

Post a Comment