当前位置:网站首页>shell 定时监控并处理脚本
shell 定时监控并处理脚本
2022-08-09 08:58:00 【寻找手艺人】
1. 问题描述
yarn 中mapreduce任务一直在NEW_SAVING状态hold不动,导致后续任务不能正常秩序。
2.脚本内容
现写如下脚本,达到定时监控并处理
oo.sh
#!/bin/bash
if [[ ! -s /usr/local/job_env/shell/NEW_SAVING.txt ]]; then
echo -e `yarn application -list -appStates NEW_SAVING |grep application_ |grep -v yarn-ats |awk '{print $1}' >/usr/local/job_env/shell/NEW_SAVING.txt`
else
appids=$(cat /usr/local/job_env/shell/NEW_SAVING.txt)
current_appids=`yarn application -list -appStates NEW_SAVING |grep application_ |grep -v yarn-ats |awk '{print $1}'`
#echo "---------------------定义空数组------------------------------"
declare -a curr_arr
curr_arr=()
index=0
#echo "---------------------遍历当前appids--------------------------"
for item in $current_appids
do
# echo "###"$item
if [[ "${appids[@]}" =~ "${item}" ]]; then
#echo "$item exists"
echo `yarn app -kill ${
item}`
else
#echo "$item not exists"
curr_arr[$index]=$item
let index+=1
fi
done
index=0
#echo "---------------------校验------------------------------------"
if [[ ${#curr_arr[@]} -eq 0 ]];then
echo `cat /dev/null>/usr/local/job_env/shell/NEW_SAVING.txt`
else
echo ${curr_arr[@]}>/usr/local/job_env/shell/NEW_SAVING.txt
fi
fi
3.定时任务
crontab表达式,每日00点到10点之间,每半小时执行一次
*/30 00-10 * * * /usr/local/oo.sh>>/usr/local/log/cron_oo.log
边栏推荐
- requests爬取百度翻译
- 基于蓝牙定位功能开发的医院智能导航系统
- NodeMCU(ESP8266) 接入阿里云物联网平台 踩坑之旅
- Shell programming loop statement and function
- BUUCTF MISC Writing Notes (1)
- UE4 RTS 框选功能实现
- go Antlr重构脚本解释器如何实现
- .net 控件calendar 基础用法
- 小程序调用百度api实现图像识别
- parse <compoN> error: Custom Component‘name should be form of my-component, not myComponent or MyCom
猜你喜欢
【场景化解决方案】构建设备通讯录,制造业设备上钉实现设备高效管理
1. LVGL 8.3 在 Visual Studio 2019 模拟器中的环境搭建
+ 6000 words, help you understand the Internet architecture evolution.
[Vulnerability reproduction] CVE-2018-7490 (path traversal)
医院智能3D蓝牙导航导诊系统
PID控制电机输出作为电机PWM占空比输入的理解
QT设置exe可执行文件的图标
web3到底是什么?
XCTF高校战“疫”网络安全分享赛Misc wp
ASEMI整流桥GBJ810参数,GBJ810封装,GBJ810重量
随机推荐
.net 控件calendar 基础用法
gin中模型中增删改查+搜索分页
PoPW token distribution mechanism may ignite the next bull market
消息中间件(MQ)前置知识介绍(必看)
mysql-5.5.40的完全卸载
parse <compoN> error: Custom Component‘name should be form of my-component, not myComponent or MyCom
Makefile中的%标记和系统通配符*的区别
内存监控以及优化
【GNN】2022 G-Mixup: Graph Data Augmentation for Graph Classification
深度学习时代的视频理解综述
VoLTE基础自学系列 | IMS的业务触发机制
智慧图书馆的导航方案-定位导航导览-只用一个方案全部实现
BUUCTF MISC brush notes (2)
nyoj58 最少步数(DFS)
QT程序生成独立exe程序(避坑版)
一篇文章带你熟悉 TCP/IP 协议(网络协议篇二)
Shell programming loop statement and function
BUUCTF MISC刷题笔记(二)
这下你知道为什么程序员要和产品干架了吧?
常用SQL server语句