Normally, when you want to redirect (standard) output of a script to a file, you run it with a redirection, like:
However – you can also accomplish the same from inside the script by using exec. The following will write “Test” and then current time into /tmp/out.log”
You can find more information about exec on tldp.