A new round of articles in my System Administration Toolkit has just started, and the first one looks at how to write scripts that can run unattended with logging and error recovery. To quote the article contents:
Look at how to create scripts that are able to record their output, trap and identify errors, and recover from errors and problems so that they either run correctly or fail with a suitable error message and report. Building scripts and running them automatically is a task that every good administrator has to handle, but how do you handle the error output and make intelligent decisions about how the script should handle these errors? This article addresses these issues.