shell 定时监控输出网络信息

for 循环,打印时间,在执行命令

for ((i=0;i<=100000;i++))

do
   date >> 20190604.txt
   echo -e "lsof -i:22 \n\n\n\n\n\n\n" >> 20190604.txt
   lsof -i:22 >> 20190604.txt
   echo -e "netstat \n\n\n\n\n\n\n" >> 20190604.txt
   netstat -an| grep '10.76.184.162:22' |grep tcp6 >> 20190604.txt
   echo -e "broker \n\n\n\n\n\n\n" >> 20190604.txt
   lsof -i:22  | grep 68883 >> 20190604.txt
   echo -e "tomcat \n\n\n\n\n\n\n" >> 20190604.txt
   lsof -i:22  | grep 6331 >> 20190604.txt
   echo -e " \n\n\n\n\n\n\n" >> 20190604.txt
   sleep 50
done

  
    展开阅读全文