我想将sqoop作业日志发送到我的邮件ID,我在shell脚本中运行sqoop作业。 我想在邮件正文中添加一些邮件,我需要将其发送到多个电子邮件ID
答案 0 :(得分:0)
您需要将sqoop作业日志重定向到一个文件并将其附加到电子邮件中,下面是它的代码,请用#阅读注释以了解它的作用。
#!bin/bash
set -x
#Parameters used below
EMAIL_MESSAGE="Someemail message the you want to send"
#Something like SqoopJob@localhost.com from address before @
FROM_ADDRRESS="SqoopJob"
SUBJECT="email subject"
#Your directory path to save the file
TEMP_DIR="/some/path/"
CC="user1@gmail.com"
TO"user2@yahoo.com"
#redirect your sqoop job log to a file #Something like below
sqoop-import --connect jdbc:mysql://localhost/db --username root --table employee --m 1 >> ${TEMP_DIR}/SqoopLogFileTosend.txt
#Sending email with attachment
echo -e "${EMAIL_MESSAGE}" | mailx -r "${FROM_ADDRRESS}" -s "${SUBJECT}" -a ${TEMP_DIR}/SqoopLogFileTosend.txt -c ${CC} -- ${TO}