当前位置:网站首页>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
边栏推荐
猜你喜欢
[Vulnerability reproduction] CVE-2018-12613 (remote file inclusion)
Tencent cloud server is modified to root login to install pagoda panel
【场景化解决方案】OA审批与金智CRM数据同步
BUUCTF MISC Writing Notes (1)
Regular Expressions for Shell Programming
BUUCTF MISC brush notes (2)
100句话,是否会触动你?
Dark Horse 2022 latest redis course notes and knowledge points (for interview)
Redis redis 】 【 the expiration of listening
UE4 RTS frame selection function implementation
随机推荐
gin中改进版curd接口例子
Redis缓存设计
Makefile中patsubst、wildcard、notdir的使用
makefile - 学习小结
权限管理模型 ---- ACL、RBAC和ABAC(详解)
【GNN】2022 G-Mixup: Graph Data Augmentation for Graph Classification
UE4 RTS frame selection function implementation
Where does detection go forward?
长辈相亲
没有对象的可以进来看看, 这里有对象介绍
.net 控件calendar 基础用法
Calendar类和Date类转换时区 && 部分时区城市列表
公司从零开发微信小程序流程
leetcode 32. 最长有效括号 (困难)
hdu2191 多重背包(2016xynu暑期集训检测 -----B题)
makefile的foreach、filter、filter-out函数
解决iframe跳转时父页面仍然存在的问题
无符号整数文法和浮点数文法
这下你知道为什么程序员要和产品干架了吧?
【场景化解决方案】OA审批与金智CRM数据同步