自定义日志函数和前期变量
# adirname - return absolute dirname of given file adirname() { odir=`pwd`; cd `dirname $1`; pwd; cd "${odir}"; } MYNAM=`basename "$0"` MYDIR=`adirname "$0"` MYHOME="/home/shell/script" MYLOG_PATH="${MYHOME}/logs" MYLOG="${MYLOG_PATH}/${MYNAM}_`date +%F`.log" # function logging function loginfo(){ echo "$1" echo "$(date -d today +"%Y%m%d %H:%M:%S") - $1" >> ${MYLOG} 2>> ${MYLOG} }
调用日志函数
loginfo "backup file war successfully!"
原文地址:https://www.cnblogs.com/xzlive/p/9470379.html
时间: 2024-09-30 07:32:32