Skip to content

Instantly share code, notes, and snippets.

@glavk
Created November 21, 2021 07:49
Show Gist options
  • Save glavk/d97c3c02ffbd6a433f79b3cc36c64932 to your computer and use it in GitHub Desktop.
Save glavk/d97c3c02ffbd6a433f79b3cc36c64932 to your computer and use it in GitHub Desktop.
Log scripts errors

Example of logging script error, e.g. cron job

Simulate output to stderr with exit code 1 and write stderr to fail.log. Then proccess file as you want, e.g. send message to slack.

(echo "Test error" >&2; exit 1) 2>>/tmp/fail.log || cat /tmp/fail.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment