当前位置:网站首页>bash汇总线上日志
bash汇总线上日志
2022-06-29 14:39:00 【代元培】
#!/bin/bash
#日期
if [ ! $1 ]; then
echo -e '日期必传,样例:20220620'
exit;
fi
date=$1
#日志总文件
logFile='/home/work/errorlog/error_'$date'.log'
#用户
user='daiyuanpei'
#删除原来的log总文件
rm -rf $logFile
#获取所有机器的ip和序号
iplist=`get_instance_by_cloudapp -io projectName.pay`
#for的分隔符设为换行,原本是空格和换行
IFS=$'\n'
#循环所有机器
for i in $iplist
do
#获取每个机器的ip和序号
ip=`echo $i | awk '{print $2}'`;
offset=`echo $i | awk '{print $3}'`;
eachLogFile='/home/work/errorlog/log_'$offset'.log'
#scp把log文件拷贝过来
scp [email protected]$ip:/home/work/project-name/logs/$date/error.log $eachLogFile
#判断如果不是文件则跳出本次循环
if [ ! -f "/home/work/errorlog/log_$offset.log" ];then
continue
fi
#把每个日志汇入到总日志当中
awk -v fileno=${offset} '{print fileno,"--",$0}' $eachLogFile >> $logFile
#删除每个小日志文件
rm -rf $eachLogFile
done边栏推荐
- Configuration tutorial for swagger2
- Chinese garbled code output from idea output station
- VQA needs not only pictures, but also external knowledge! University of Washington & Microsoft proposed revive, using gpt-3 and wikidata to help answer questions
- 宜明昂科冲刺港股:年内亏损7.3亿 礼来与阳光人寿是股东
- 捷氢科技冲刺科创板:拟募资10.6亿 上汽集团是大股东
- The first lesson on cloud - how easy is it to build a small broken station? The old driver of cloud computing will take you one hour to finish it
- PostgreSQL learning (based on rookie course)
- wieshark抓包mysql协议简单分析
- 华曙高科冲刺科创板:拟募资6.6亿 实控人许小曙父子均为美国籍
- Yi Ming ang Ke rushed to Hong Kong shares: loss of 730million in the year Lilly and sunshine life insurance were shareholders
猜你喜欢

Is 100W data table faster than 1000W data table query in MySQL?

【Try to Hack】vulnhub DC2

宜明昂科冲刺港股:年内亏损7.3亿 礼来与阳光人寿是股东

Deploy redis sentry in k8s

Stm32 mbed tutorial (IV) --pwm

Redis installation in windows and Linux Environment

华理生物冲刺科创板:年营收2.26亿 拟募资8亿

Uniapp problem list and experience

Huashu high tech rushes to the scientific innovation board: the actual controller xuxiaoshu and his son, who plan to raise 660million yuan, are both American nationals

June 27 talk SofiE
随机推荐
阿尔兹海默病智能诊断
Using polymorphism to realize simple calculator
The 5th China software open source innovation competition | opengauss track live training
Laravel - composer installs the specified laravel version
Laravel - Composer 安装指定 Laravel 版本
信息学奥赛一本通1001:Hello,World!
k8s部署redis哨兵
word如何自动生成目录
第五届中国软件开源创新大赛 | openGauss赛道直播培训
两个字的名字如何变成有空格的3个字符的名字
Alibaba cloud experience Award: use polardb-x and Flink to build a large real-time data screen
PostgreSQL learning (based on rookie course)
捷氢科技冲刺科创板:拟募资10.6亿 上汽集团是大股东
部署搭建decentraland流程讲解
建立自己的网站(19)
MCS:离散随机变量——几何分布
Query function of Excel vlookup
Unity C# 基础复习29——泛型委托(P451)
Chapter 10 of canvas path
kubernetes Unable to connect to the server: x509: certificate has expired or is not yet valid