当前位置:网站首页>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边栏推荐
- wieshark抓包mysql协议简单分析
- 知乎热议:一个程序员的水平能差到什么程度?
- Asynchronous artifact completable future
- Unity C# 基础复习27——委托示例(P448)
- 两个字的名字如何变成有空格的3个字符的名字
- Using polymorphism to realize simple calculator
- Evaluation index of high concurrency software (website, server interface)
- ROS 笔记(10)— launch 文件启动
- phpcms打开后台首页时向官网发送升级请求觉得卡怎么办?
- 信息学奥赛一本通1003:对齐输出
猜你喜欢

Trigonometric function corresponding to drawing circle on plane coordinate

redis在window和Linux环境下的安装

Source code of campus secondary market

EXCEL的查询功能Vlookup

Analysis of constant current source circuit composed of two NPN tubes

ROS 笔记(10)— launch 文件启动

论文学习——考虑场次降雨年际变化特征的年径流总量控制率准确核算

What should phpcms do when it sends an upgrade request to the official website when it opens the background home page?

阿尔兹海默病智能诊断

ModStartBlog 现代化个人博客系统 v5.2.0 主题开发增强,新增联系方式
随机推荐
Differences between @resource and @autowired annotations automatically injected:
Can futures accounts be opened offline? Is it safe to open an account online?
redis在window和Linux环境下的安装
云上第一课 | 建个小破站有多简单?云计算老司机带你一小时搞定
phpcms打开后台首页时向官网发送升级请求觉得卡怎么办?
华理生物冲刺科创板:年营收2.26亿 拟募资8亿
openGauss社区成立SIG KnowledgeGraph
China soft ice cream market forecast and investment prospect research report (2022 Edition)
Jet hydrogen technology rushes to the scientific innovation board: SAIC Group is the major shareholder to raise 1.06 billion yuan
PostgreSql学习(基于菜鸟课程)
Methods of accessing external services in istio grid
Configuration tutorial for swagger2
[Verilog quick start of Niuke online question series] ~ shift operation and multiplication
Interview shock 61: tell me about MySQL transaction isolation level?
Thanos store component
I log in to the RDB database and prompt that the master account authorization is required. How do I know who to call?
类模板案例-【数组类封装】
Chapter 13 event operation of canvas
JS will have variable promotion and function promotion
Trigonometric function corresponding to drawing circle on plane coordinate