Logging shell scripts' executions
Small hack. Do you have a bash
1 script that runs via cron
or incron
or
any other daemon, and you wanna debug it by at least tracing its execution? Well,
simply surround it by:
( set -x ... ) > /tmp/$0-$(date +%F.%T).log
But! Do not make the same mistake I did and forget to redirect stderr
too2!:
) > /tmp/$0-$(date +%F.%T).log 2>&1
I know there is a shortcut for that, but I'm too lazy to look it up.