INFO-批量取消调度任务

适用模块

azkaban

具体说明

批量取消demo环境长期未修改过的调度任务

使用示例

#!/bin/bash
#获取curl返回信息(请求az web节点)
resport=`curl https://ip:8443 -k -X POST -d 'action=login&username=hadoop&password=azkabanAdmin'`
echo resport=$resport
#从resport截取session信息并去除逗号、引号
session=`echo $resport |awk '{print $4}' |sed 's/\"//g' |sed 's/,//g'`
echo session=$session
#IFS=$'\t'
#以近60天未更新为例
SQL="select trigger_id from triggers where mammut_user != 'dsc_support' and modify_time < unix_timestamp(date_sub(curdate(),interval 60 day)) * 1000 group by trigger_id"
user_attrs=(`mysql -h xxx -P 3306 -uxxx -pxxx azkaban   -Ne "${SQL}"`)
echo "数组长度是${#user_attrs[*]}"
for (( i=0; i<${#user_attrs[*]}; i=i+1))
do
  echo "第$i个trigger_id为:${user_attrs[i]}"
  echo 'curl https://xxx:8443/schedule -k -X POST -d "action=removeSched&scheduleId=${user_attrs[i]}&proxy.user=bdms_linshuai&proxy.email=linshuai@corp.netease.com&session.id=${session}"'
curl https://xxx:8443/schedule -k -X POST -d "action=removeSched&scheduleId=${user_attrs[i]}&proxy.user=bdms_linshuai&proxy.email=linshuai@corp.netease.com&session.id=${session}"
done

INFO-批量取消调度任务 - 图1


作者:林帅