#!/bin/bash day=`date +%Y%m%d_%H%M` log_dir=/usr/local/share/zabbix/alertscripts/log name=`echo $1 |awk [email protected] ‘{print $1}‘` function redirect_log () { log_file=$log_dir/mail_${day}_$name.log log_err=$log_dir/mail_${day}_$name.err.log mkdir -p $log_dir exec 1>$log_file exec 2>$log_err } # ---------- end of function redirect_log ---------- redirect_log echo "$3" | mailx -s "$2" $1 [ $? -eq 0 ] && echo "mailto:$1 sub:$2 content:$3 Successfull." || echo "mailto:$1 sub:$2 content:$3 Failed."
时间: 2024-11-11 15:38:16