In Linux, write a monitoring log and mail shell.

Source: Internet
Author: User

Back_day = 'date-d' 1 day ago '+ % Y-% m-% d'

Finance_linux_log_user =/home/admin/output/logs/user

Target_server = "crmfinance1 crmfinance2 crm-finance03"
Target_gov_auto_draft =$ {finance_linux_log_user}/govautodraft. log. $ {back_day}
Target_gov_auto_draft_log_folder =$ {finance_linux_log_user}/back_govautodraft
Target_gov_auto_draft_log_tmp =$ {target_gov_auto_draft_log_folder}/govautodraft. log. tmp

Target_gov_auto_exception =$ {target_gov_auto_draft_log_folder}/govautodraftexceptiom

If [! -D "$ {target_gov_auto_draft_log_folder}"]; then
Mkdir $ {target_gov_auto_draft_log_folder}
Fi

For a_machine in $ {target_server}
Do

SSH $ {a_machine} test-F $ {target_gov_auto_draft}
If [$? -EQ 0]; then
SCP admin @ $ a_machine :$ {target_gov_auto_draft }$ {target_gov_auto_draft_log_tmp}>/dev/null
If ['cat $ {target_gov_auto_draft_log_tmp} | grep 'inititon' | WC-l'-GT 0]; then
Echo $ a_machine >>$ {target_gov_auto_exception}
Cat $ {target_gov_auto_draft_log_tmp} | grep 'inititon' >>$ {target_gov_auto_exception}

Rm-RF $ {target_gov_auto_draft_log_tmp}
Fi
Fi
Done

If [-F "$ {target_gov_auto_exception}"]; then
smtpclient-s 172.16.126.67-P 25-F result@member.alibaba.com-s 'There are exception in govautodraft operatio' dragon.caol@alibaba-inc.com di.caod@alibaba-inc.com <$ {target_gov_auto_exception}
MV $ {target_gov_auto_exception} $ {target_gov_auto_exception }. $ {back_day}
RM-RF $ {target_gov_auto_exception}
fi

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.