1#! /bin/Bash2deploy_path=$ (CD"$ (dirname"$0")";pwd)3ini_file= $DEPLOY _path'/cnedmp_etl.ini'4 . $INI _file5base_path=$ (CD"$ (dirname"$DEPLOY _path")";pwd)6main_path=$ (CD"$ (dirname"$BASE _path")";pwd)7Currrent_date= 'Date-U +\%y\%m\%d '8Current_time= 'Date-U +"%y%m%d%t"`9Log_path= $BASE _path'/log/'Tenrecord_file= $LOG _path'EMAILRECORD.RCD' One A#Echo$value |sed 's/[0-9]\{1,\}/30/g' -#sed-I.'s/[0-9]\{1,\}/30/g'Test.txt -#sed-I.'S/^load_check.20170803.log.*[0-9]\{1,\}/load_check.20170803.log 178/g'EMAILRECORD.RCD the - CD $LOG _path -Test-e $RECORD _file | |Touch$RECORD _file - +Loglist= 'ls$LOG _path |grep "${currrent_date}.log"` -#Echo$loglist + A at #Use to store email cotent -Email_message="" - for logname inch$loglist - Do -#Echo$logname -Prc_exist= 'Cat$RECORD _file |grep "$logname"` inTest-z"${prc_exist}" - if[$?-eq0]; Then toPrc=0 + Echo "$logname ' cat $logname | wc-l '">>$RECORD _file - Else thePrc= 'Echo$PRC _exist |awk-F' ' '{print $NF}'` *Nrc= 'Cat$logname|WC-l ' $ sed-I."s/^ $logname. *[0-9]\{1,\}$/$logname $NRC/g"$RECORD _filePanax Notoginseng fi - theTmp_message="" +Warn_message= 'Cat$logname|Tail-N +$[$PRC +1] |grep "WARN"` ATest-z"${warn_message}" the if[$?-ne0 ] + Then -Tmp_message="${tmp_message}warn message:\\n${warn_message}\\n" $ fi $Fatal_message= 'Cat$logname|Tail-N +$[$PRC +1] |grep "FATAL"` -Test-z"${fatal_message}" - if[$?-ne0 ] the Then -Tmp_message="${tmp_message}fatal message:\\n${fatal_message}\\n"Wuyi fi theTest-z"${tmp_message}" - if[$?-ne0 ] Wu Then -Email_message="${email_message}\\n${logname}:\\n${tmp_message}\\n" About fi $ Done - -Test-z"${email_message}" - if[$?-ne0 ] A Then + the#/usr/sbin/sendmail"[email protected]"<<EOF -#subject: <failed job/fileEtc> $ #from: Edmpcn.etl the#"Below is WARN and FATAL: \\n"$email _message the #EOF the theemail_log="/home/infra1/jason/workspace/logs/emaillog/""sendmail. $CURRENT _time.log" - Echo-E"Below is WARN and fatal:\\n${email_message}">$email _log in the fi
Post a shell for reference