您的位置:首页 > 其它

多台日志汇聚一个terminal实例

2015-12-18 17:33 429 查看
#!/bin/bash
echo $@
#tmp1=${tmp[*]}
function jkill() {
kill -9 $@
}
if [ $# -lt 1 ];then
ssh web@10.1.5.130 tail -f /data/web/tomcat/tomcat7-creditLoan/logs/catalina.out | awk '{print "10.1.5.130--"$0}' &
pid_1=$!
ssh web@10.1.5.131 tail -f /data/web/tomcat/tomcat7-creditLoan/logs/catalina.out |awk '{print "10.1.5.131--"$0}' &
pid_2=$!
ssh web@10.1.5.130 tail -f /data/web/tomcat/tomcat7-creditLoan-task/logs/catalina.out |awk '{print "10.1.5.130.1--"$0}' &
pid_3=$!
else
ssh web@10.1.5.130 tail -f /data/web/tomcat/tomcat7-creditLoan/logs/catalina.out | grep $@ |awk '{print "10.1.5.130--"$0}' &
pid_1=$!
ssh web@10.1.5.131 tail -f /data/web/tomcat/tomcat7-creditLoan/logs/catalina.out | grep $@ |awk '{print "10.1.5.131--"$0}' &
pid_2=$
ssh web@10.1.5.130 tail -f /data/web/tomcat/tomcat7-creditLoan-task/logs/catalina.out |grep $@ |awk '{print "10.1.5.130.1--"$0}' &
pid_3=$!
fi
trap "kill -9 ${pid_1} ${pid_2} ${pid_3};exit 0" SIGTERM SIGKILL SIGQUIT SIGSTOP SIGTSTP SIGCHLD SIGINT
while true;do
sleep 100
done

log.sh |grep "10.1.5.130"

log.sh|grep -v "10.1.5.130.1"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: