#!/bin/sh ### Logging everything written to standard/standard error to a ### log file in sh and ksh. ### ### This is how to send all output from any program or echo executed ### by a script to a file for logging purposes. ### # Sends standard out and standard error to a log now=`date '+%d%m%y-%H:%M'` exec 1>/var/tmp/log.${now} 2>&1 # Do whatever and the output will be logged to the logfile above echo "This is logging to the output file" echo "" echo "" ### Example of outputting a command echo "Disk sizes:" /bin/df -kl ### Exit exit 0 ############################################################################## ### This script is submitted to BigAdmin by a user of the BigAdmin community. ### Sun Microsystems, Inc. is not responsible for the ### contents or the code enclosed. ### ### ### Copyright 2006 Sun Microsystems, Inc. ALL RIGHTS RESERVED ### Use of this software is authorized pursuant to the ### terms of the license found at ### http://www.sun.com/bigadmin/common/berkeley_license.html ##############################################################################