根据项目找到主机清除日志脚本


#!/bin/bash
DATA=/data/prog/project
IP1=172.16.1.41
IP2=172.16.1.42
IP3=172.16.1.43
IP4=172.16.1.44
IP5=172.16.1.45
IP6=172.16.1.46
IP7=172.16.1.49
IP8=172.16.1.50
IP9=172.16.1.51
IP10=172.16.1.52

if [ $1 == 'oauth-server' ] || [ $1 == 'wxauth' ]; then
chdir=$DATA/$1/logs
ansible $IP1 -m shell -a " > $DATA/$1/logs/$1-console.log"
ansible $IP2 -m shell -a " > $DATA/$1/logs/$1-console.log"
if [ $? == 0 ]; then
echo "-----$1日志清除成功-----"
else
echo "-----请检查项目名字-----"
fi

elif [ $1 == 'activity_server' ] || [ $1 == 'app_agency' ] || [ $1 == 'base_push_server' ] || [ $1 == 'channel_server' ] || [ $1 == 'community_server' ] || [ $1 == 'education_server' ] || [ $1 == 'manage_agency' ] || [ $1 == 'member_server' ] || [ $1 == 'server_advert' ] || [ $1 == 'shop_server' ] || [ $1 == 'vod_server' ] || [ $1 == 'wlan_server' ] || [ $1 == 'ai_server' ] || [ $1 == 'app-live' ] || [ $1 == 'base_server' ] || [ $1 == 'city_business_card' ] || [ $1 == 'credit_server' ] || [ $1 == 'im_server' ] || [ $1 == 'manage-live' ] || [ $1 == 'pay_server' ] || [ $1 == 'server_zhixiangtuike' ] || [ $1 == 'tour_distributor' ] || [ $1 == 'web-data-center' ] || [ $1 == 'xxl_job' ]; then
chdir=$DATA/$1/logs
ansible $IP3 -m shell -a " > $DATA/$1/logs/$1-console.log"
ansible $IP4 -m shell -a " > $DATA/$1/logs/$1-console.log"
if [ $? == 0 ]; then
echo "-----$1日志清除成功-----"
else
echo "-----请检查项目名字-----"
fi
elif [ $1 == 'app_enterScene_after' ] || [ $1 == 'app_enter_scenic' ] || [ $1 == 'app_tourism' ] || [ $1 == 'mini_apps_tourism' ] || [ $1 == 'nkb_manage' ] || [ $1 == 'nk_manage' ] || [ $1 == 'push_server' ] || [ $1 == 'scene_manage' ] || [ $1 == 'user_center' ]; then
chdir=$DATA/$1/logs
ansible $IP5 -m shell -a " > $DATA/$1/logs/$1-console.log"
ansible $IP6 -m shell -a " > $DATA/$1/logs/$1-console.log"
if [ $? == 0 ]; then
echo "-----$1日志清除成功-----"
else
echo "-----请检查项目名字-----"
fi
elif [ $1 == 'app-distributor' ] || [ $1 == 'app-member' ] || [ $1 == 'app-shop' ] || [ $1 == 'community_im' ] || [ $1 == 'digital_config' ] || [ $1 == 'finance-service' ] || [ $1 == 'shop' ] || [ $1 == 'web-coupon' ] || [ $1 == 'web-distributor' ] || [ $1 == 'web-member' ] || [ $1 == 'web-shop' ]; then
chdir=$DATA/$1/logs
ansible $IP7 -m shell -a " > $DATA/$1/logs/$1-console.log"
ansible $IP8 -m shell -a " > $DATA/$1/logs/$1-console.log"
if [ $? == 0 ]; then
echo "-----$1日志清除成功-----"
else
echo "-----请检查项目名字-----"
fi

elif [$1 == 'app_butler' ] || [ $1 == 'app_community' ] || [ $1 == 'city_card' ] || [ $1 == 'sms_butler' ] || [ $1 == 'sms_community' ] || [ $1 == 'web_butler' ] || [ $1 == 'web_community' ] || [ $1 == 'web_sms' ]; then
chdir=$DATA/$1/logs
ansible $IP9 -m shell -a " > $DATA/$1/logs/$1-console.log"
ansible $IP10 -m shell -a " > $DATA/$1/logs/$1-console.log"
if [ $? == 0 ]; then
echo "-----$1日志清除成功-----"
else
echo "-----请检查项目名字-----"
fi
fi

posted @ 2021-09-22 19:29  虞岩  阅读(65)  评论(0编辑  收藏  举报