Friday, November 23, 2012

Redirect all output in shell script to a file







REF: http://www.thetechrepo.com/main-articles/532


(
echo "this is line 1 of my script"
cat /proc/cpuinfo
dmesg
echo "this is the end of my script"
) 2>> /tmp/filename.log



typeset log_fl=`basename $0`_` date +'%H%M%S'`.log
  # sending this script output to the log file
exec 1>${log_fl}

No comments:

Post a Comment

Labels