Files
mastering-unix-ss/chapter28/function_cleanup_exit
Fabio Scotto di Santolo 4cc88d2f6e initial commit
2020-07-28 19:28:25 +02:00

16 lines
525 B
Plaintext
Executable File

cleanup_exit ()
{
# This function is executed on any type of exit except of course
# a kill -9, which cannot be trapped. The script log file is
# emailed either locally or remotely, and the log file is
# compressed. The last "exit" is needed so the user does not
# have the ability to get to the command line without logging.
if [[ -s ${LOGDIR}/${LOGFILE} ]] # Is it greater than zero bytes?
then
mailx -s "$TS - $LOGNAME Audit Report" $LOG_MANAGER < ${LOGDIR}/${LOGFILE}
nohup compress ${LOGDIR}/${LOGFILE} &
fi
}