Bash - Script to add logging features to your script
Also read Bash - Echo on the console and in a logfile in the same time
When you write Bash scripts and certainly when you foresee running them in a cron, you should implement a logfile. Every action fired by your script should be logging somewhere so you can start the script in a non-interactive mode and in case of need, consult the last logfile.
Below is a script I've developed in the form of a library, which means you can easily include it in your existing code without having to change anything.
You just need to include the file in your script (i.e. add a source log.sh
line) then here and there foresee a log::write "Something to log"
. Easy no?