Detailed Error Handling In Bash
Shell scripts are often running as background processes, doing useful things without running in a visible shell. To write such scripts can be quite painful, as all errors occur out of sight as well. While log files can hold a lot of information, finding the relevant information is a bit trickier. My solution is to log only the errors with all the details to a small database. This database contains tables for the message, the corresponding stack trace and the important environment variables. I have chosen for an SQLite database in this howto, but the same principle works with other databases as well.
HowtoForge – Linux Howtos and Tutorials – Linux