This is what I'm using as a header in all the scripts I write now. It makes it easy to adapt scripts on the fly.
Further improvements I'm going to make, when I have time:
Make the script read a central configuration file that specifies which one of the following three modes it should use, so I can
easily switch all my scripts between debugging and discarding information.
Possibly make it so the configuration file has an entry for each script so they can look up to see what mode they should function
under (using the $0 parameter)
# Log all output to a file for later viewing (For Cron jobs that need monitoring)
# Don't echo anything at all (For Cron jobs that have been tested sufficiently and don't need to show up in the log)
# For when I run it myself from the commandline and want to see all output.
## Code with, for example:
echo "Download completed" >> $OUTPUT
echo "The year is $(date +%Y), and the time is $(date +%T)" >> $OUTPUT