I am running my raspberry PI in a head-less fashion and it is therefore very valuable to be notified of certain events.

So I should be able to do something like the following:

/usr/bin/log_message "Something just happened"

I then want to be notified about this on my work station using growl or slack.


The Slack Script

  1. Configure a new Incoming Webhook through slack https://YOURTEAM.slack.com/services/new

  2. You'll get a custom URL that will be used later on. So make sure to replace it with any occurences of the URL template:

  3. Create a binary and add the contents below

    touch /usr/bin/slack
    chmod +x /usr/bin/slack
    nano /usr/bin/slack
  4. The Script:

        curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"username\": \"$USERNAME\", \"icon_emoji\": \"$ICON\"}" -k $SLACK_URL
  5. Add the following line to ~/.profile. This ensures that the slack command can be used inside a terminal:

    export SLACK_URL=https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX


Get notified when Raspberry PI starts up:

touch /etc/init.d/startup_notification.sh
chmod +x /etc/init.d/startup_notification.sh
update-rc.d startup_notification.sh defaults
nano /etc/init.d/startup_notification.sh

The script startup_notification.sh:


export SLACK_URL=export SLACK_URL=https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
/usr/bin/slack "The raspberry PI has started up \n> $(uname -a)\n$(ifconfig)" &

This gives me a nice notification along with the network details:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.