logger.bsh

“Потерял” скрипт, сохраню-ка его здесь.

#!/bin/bash

LOGDIR="/storarray/work/slogs"

silent=yes      # uncomment for silent mode
debug=yes       # uncomment for debug
#detach=yes  # uncomment for detach

[ -z ${debug:+x} ] || set -x
#[ -z ${detach:+x} ] || nohup -pa $$ ### solaris option
[ -z ${silent:+x} ] || {
        [ -d ${LOGDIR} ] || mkdir ${LOGDIR}
        LOGFILE="${LOGDIR}/`basename $0`.txt-`date +'%Y-%m-%d_%H-%M-%S'`"
        [ -f "${LOGFILE}" ] || touch "${LOGFILE}"
        exec 1>> $log_file 2>&1 & # silent mode
        exec &> >(tee -a "${LOGFILE}")
}

Использовать просто: . ~/bin/logger.bsh. Ну а дальше все в файл попадает…

Leave a Reply

Your email address will not be published. Required fields are marked *