分享一个AIX系统自动发送邮件并添加附件的脚本,脚本如下:
#!/usr/bin/ksh #---------------------------------------------------------------# # Script Name : HMH KSH BACKUP Shell # Created by : Xin23 # on : 2015.02.05 #---------------------------------------------------------------# # Define Backup Directory export HMHKSHBACKUPDIR=/backup/HMH_KSH_BACKUP # Define File Name Prefix & File Date export FILENAMEPREFIX=$(date +%Y%m%d)_$(hostname) export FILEDATE=$(date +%Y%m%d) # Define Data Directory export DATA_DIR=/data/ksh # Main cd $DATA_DIR cp FPPM1001.dat FPZZ1001.dat FPZZ1002.dat MODELBOM.dat $HMHKSHBACKUPDIR cd $HMHKSHBACKUPDIR tar cvf DataFile_$FILEDATE.tar *.dat gzip -9 DataFile_$FILEDATE.tar uuencode DataFile_$FILEDATE.tar.gz HMH_KSH_BACKUP_$FILENAMEPREFIX.tar.gz > DataFile_Temp.tar.gz cat HMHKSHMAILMSG DataFile_Temp.tar.gz >> DataFile_Send.tar.gz mail -s "XX环境XX数据备份$FILENAMEPREFIX" -c "[email protected]" [email protected] < DataFile_Send.tar.gz rm -f *.dat rm -f DataFile_Temp.tar.gz DataFile_Send.tar.gz
时间: 2024-11-05 11:56:26