Sending a scripts output to a log file

Thought I’d post this link as it took a bit of digging.

If you need to create scripts for other users to use they need it to be as simple as possible – so no using ;script’ etc.  You may also need to see what the output of their scripts are in case an error occurs.

I’ve based my answer on:

and to create nice separate log files at the top of the script I put.

mkdir -p ~/logs/pullpush
DATE_TIME=`date +%Y%m%d-%H%M%S`
mkfifo ${logfile}.pipe
tee < ${logfile}.pipe $logfile &
exec &> ${logfile}.pipe
rm ${logfile}.pipe


Share Post :