six demon bag
Wind, fire, all that kind of thing!
2020-02-24
Shell Patterns (1) - Logging
This is a short series describing some Bash constructs that I frequently use in my scripts.
What do you do when you run fully automated scripts in the background, but still want to keep track of what they're doing and, more importantly, when something goes wrong? The answer is, of course, you log what the script is doing (or is about to do).
There are two commonly used ways of implementing logging in Bash scripts:
- redirecting output to files
- invoking the
logger
command for logging to syslog
Personally, I prefer the latter, since it allows not only for managing log files independently of the process creating the log output, but also for filtering log data and/or forwarding it to a central loghost.
Posted 20:47 [permalink]