linux 單行命令

wangzhensheng發表於2009-05-25

懶的寫指令碼,一行執行多個命令

#########
zcat web-20090523.log |grep 'Sat2009/05/23:08'| grep '117.25.54.125' | awk '{print $6"t"$10"t"$11"t"$12"t"$13"t"$14"t"$15"t"$16"t"$17"t"$18"t"$19"t"$20"t"$21}' | more
###########
while : ; do date ;echo "" ;sleep 30 ; date >>/tmp/h/web-1 ; ssh web-1 netstat -anlp |grep tcp | grep -v ESTABLISHED |grep TIME_WAIT |awk -F: '{print $8}' | grep '[0-9]' | sort | uniq -c | sort -r >>/tmp/h/web-1 ;date >>/tmp/h/web-2 ; ssh web-2 netstat -anlp |grep tcp | grep -v ESTABLISHED |grep TIME_WAIT |awk '{print $5}' | awk -F: '{print $1}' | grep '[0-9]' | sort | uniq -c | sort -r >>/tmp/h/web-2;date >>/tmp/h/web-3 ; ssh web-3 netstat -anlp |grep tcp | grep -v ESTABLISHED |grep TIME_WAIT |awk '{print $5}' | awk -F: '{print $1}' | grep '[0-9]' | sort | uniq -c | sort -r >>/tmp/h/web-3;date >>/tmp/h/web-4 ; ssh web-4 netstat -anlp |grep tcp | grep -v ESTABLISHED |grep TIME_WAIT |awk '{print $5}' | awk -F: '{print $1}' | grep '[0-9]' | sort | uniq -c | sort -r >>/tmp/h/web-4;date >>/tmp/h/web-7 ; ssh web-7 netstat -anlp |grep tcp | grep -v ESTABLISHED |grep TIME_WAIT |awk '{print $5}' | awk -F: '{print $1}' | grep '[0-9]' | sort | uniq -c | sort -r >>/tmp/h/web-7;date >>/tmp/h/web-8 ; ssh web-8 netstat -anlp |grep tcp | grep -v ESTABLISHED |grep TIME_WAIT |awk -F: '{print $8}' | grep '[0-9]' | sort | uniq -c | sort -r >>/tmp/h/web-8;done
#############
while : ; do ps -ef | grep java | grep '-Xmn10' | awk '{print $2}' |while read pid ; do echo "$pid";echo "" ;/usr/local/bin/lsof -p $pid | grep TCP|awk '{print $9,$10}' ;echo "######################";done;done

殺掉相關程式

kill -9 `ps -ef | grep $(ps -ef | grep start_mon.sh | grep -v grep | awk '{print $2}')| grep -v grep | awk '{print $2}'`

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8806316/viewspace-1022466/,如需轉載,請註明出處,否則將追究法律責任。

相關文章