We run several processes that may take hours to complete and it is nice to be notified on a Slack channel when those processes finishes correctly. Using the Slack’s Incoming Webhooks API, a small bash script and a couple of tricks it is really simple!
Only few steps are necessary to install this small script:
- Download this bash script and place it at your home directory:
- Edit your
~/.bashrcto source the new file:
Create a file at
~/.notify-slack-cfgcontaining the Slack’s webhook. This file MUST contains only the key, it looks like
T02TKKSAX/B246MJ6HX/WXt2BWPfNhSKxdoFNFblczW9. You can create your webhook here
All done! :D
Now you can test notifications, just source your .bashrc again:
source ~/.bashrc and let’s do a few tests:
You should receive inmediatlely a notification on Slack:
If you start your message with
ERROR a nice icon will be prepended.
Chaining on your scripts
notify-slack on your own commands and scripts. I use it to be notify when a backup finished correctly:
Hope you find it useful! Enjoy!