ntfy.sh is awesome

I have a Raspberry Pi running Syncthing to keep my files in sync across different devices. However, my HDD, where Syncthing stores all the data, is encrypted, so whenever the power goes out and the Pi restarts, I have to SSH into it and unlock and decrypt the drive manually. The annoying part is that I don’t always know when the Pi has restarted. Sometimes, the Pi restarts and I go several days without knowing about it and my data starts becoming unreliable across different devices. Once I deal with that, I start having all sorts of “sync-conflicts”. It does not happen that often, but power does go out a non-negligible amount of times.

I used to deal with this problem by just sending an e-mail via SMTP to myself. Or rather, a script that ran at startup did that. I would, however, have to store credentials on the Pi and it was a bit too troublesome for my liking. Also, I sometimes go a few days without checking my e-mail and I have no e-mail notifications. So this solution did not really solve my issue.

I came across ntfy.sh while working on my vibbi.eu project. I use it there as well, for checking its health and readiness (is the server running? Is the DB working?). Uptime Kuma supports ntfy and that is how I learnt of it. status.vibbi.eu uses ntfy as its notification service, so I know when vibbi needs my attention.

The TLDR of ntfy.sh is that it is a wonderfully simple service that lets you send push notifications with a basic HTTP request. No complicated setup, and no need for extra software. Curl is all you need, and that is already available pretty much everywhere. You do need the ntfy app on your phone though. That is available on F-Droid! On my Raspberry Pi, I have just a tiny shell script and a systemd service that runs at startup. When the power goes out and the Raspberry Pi restarts, the shell script runs and I receive a notification on my phone, letting me know that my Raspberry Pi needs my attention.

ntfy.sh does absolutely everything I want from a notification system. It is seriously awesome. KISS beats complexity every single time.

The script I use is the following:

#!/bin/bash

sleep 60

TOPIC="fdsaijf3i2u4hfq3h78f23h78fhe8fh8dsaf7gh821"

while true; do
  if curl -v -f -S \
    --connect-timeout 10 \
    --max-time 15 \
    -H "Title: Raspberry Pi restarted" \
    -H "Priority: high" \
    -d "Your Raspberry Pi has restarted" \
    "https://ntfy.sh/${TOPIC}"; then
    break
  fi
  sleep 30
done

exit 0

Notice the TOPIC. Ntfy.sh topics on the public server aren’t private. Anyone who knows the topic name can potentially publish messages to it or subscribe to it. I don’t consider this a big issue for my use case, since the notifications don’t contain anything sensitive. I simply use a long, randomly generated topic name. The sleep is there because sometimes the router needs a little time to establish connectivity and curl needs an active internet connection to work. The while loop retries if an attempt fails, allowing time for the internet connection to become available later. Two layers trying to solve the same issue, also known as, resilience.

Save that script somewhere. Make it executable (chmod +x). I then use systemd to make it run at system startup.

Create a service file:

sudo vim /etc/systemd/system/pi-boot-notify.service

With contents:

[Unit]
Description=Send ntfy notification when Raspberry Pi boots
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/path-where-you-saved-the-script/pi-ntfy.sh

[Install]
WantedBy=multi-user.target

Finally, enable the systemd service:

sudo systemctl daemon-reload
sudo systemctl enable pi-boot-notify.service

Reboot your device and see if you receive the notification.


dev

600 Words

Created in 2026-10-15