#!/bin/bash
LOG_LOCATION=/var/log/scripts/logs
exec > >(tee -i $LOG_LOCATION/MylogFile.log)
exec 2>&1
echo "Log Location should be: [ $LOG_LOCATION ]"
You can add this line on top of your script:
#!/bin/bash
# redirect stdout/stderr to a file
exec &> logfile.txt
OR else to redirect only stdout use:
exec > logfile.txt