当前位置:网站首页>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
边栏推荐
猜你喜欢

微信小程序转支付宝小程序注意事项

【场景化解决方案】OA审批与用友U9数据集成

The principle and configuration of VLAN

leetcode 35. 搜索插入位置(二分法+找性质也很关键)

Regular Expressions for Shell Programming

消息中间件(MQ)前置知识介绍(必看)

Venture DAO 行业研报:宏观和经典案例分析、模式总结、未来建议

Tencent cloud server is modified to root login to install pagoda panel

ctf misc 图片题知识点

加密技术和电子竞技如何促进彼此的发展
随机推荐
【GNN终身学习】2022 CVPR 终身图学习
LAN Technology - 6MSTP
Failed to mount component: template or render function not defined.
探索APP性能优化之稳定性优化(解决方案)
nyoj306 走迷宫(搜索+二分)
The principle and configuration of VLAN
【场景化解决方案】OA审批与用友U9数据集成
LAN技术-6MSTP
支付宝小程序使用自定义组件(原生)
大学四年不努力,出社会后浑浑噩噩深感无力,辞去工作,从头开始
js实现看板全屏功能
RDMA
Kibana:为地图应用选择不同的语言 - Elastic Stack 8.3
[漏洞复现]CVE-2018-7490(路径遍历)
JVM进程诊断利器——Arthas
PID控制电机输出作为电机PWM占空比输入的理解
web3到底是什么?
Static routing principle and configuration
How does STM32 know the usage of FLASH
嵌入式之串口中断只能收到一个字节