in reply to How do I print errors

If this is a cron job, then I would suggest studying cron's documentation. You can readily have it mail error output automatically, which is generally better than putting stuff in files that are easy to ignore.

A follow-up guess. Your script is failing because it is relying on environment variables that you don't have set right in cron. For a simple way to address that, see Get default login environment.