You can add this line on top of your script:
#!/bin/bash
# redirect stdout/stderr to a file
exec >logfile.txt 2>&1
OR else to redirect only stdout use:
exec > logfile.txt
You can add this line on top of your script:
#!/bin/bash
# redirect stdout/stderr to a file
exec >logfile.txt 2>&1
OR else to redirect only stdout use:
exec > logfile.txt