Skip to content


There are a million ways to use ntfy, but here are some inspirations. I try to collect examples on GitHub, so be sure to check those out, too.

A long process is done: backups, copying data, pipelines, ...

I started adding notifications pretty much all of my scripts. Typically, I just chain the curl call directly to the command I'm running. The following example will either send Laptop backup succeeded or ⚠️ Laptop backup failed directly to my phone:

rsync -a root@laptop /backups/laptop \
  && zfs snapshot ... \
  && curl -H prio:low -d "Laptop backup succeeded" \
  || curl -H tags:warning -H prio:high -d "Laptop backup failed"

Server-sent messages in your web app

Just as you can subscribe to topics in the Web UI, you can use ntfy in your own web application. Check out the live example or just look the source of this page.

Notify on SSH login

Years ago my home server was broken into. That shook me hard, so every time someone logs into any machine that I own, I now message myself. Here's an example of how to use PAM to notify yourself on SSH login.

# at the end of the file
session optional /usr/bin/
if [ "${PAM_TYPE}" = "open_session" ]; then
  curl \
    -H prio:high \
    -H tags:warning \
    -d "SSH login: ${PAM_USER} from ${PAM_RHOST}" \

Collect data from multiple machines

The other day I was running tasks on 20 servers, and I wanted to collect the interim results as a CSV in one place. Each of the servers was publishing to a topic as the results completed (, and I had one central collector to grab the results as they came in (

It looked something like this:

while read result; do
  [ -n "$result" ] && echo "$result" >> results.csv
done < <(stdbuf -i0 -o0 curl -s
// This script was run on each of the 20 servers. It was doing heavy processing ...

// Publish script results
curl -d "$(hostname),$count,$time"

Ansible, Salt and Puppet

You can easily integrate ntfy into Ansible, Salt, or Puppet to notify you when runs are done or are highstated. One of my co-workers uses the following Ansible task to let him know when things are done:

- name: Send update
    url: "{{ ntfy_channel }}"
    method: POST
    body: "{{ inventory_hostname }} reseeding complete"

Watchtower notifications (shoutrrr)

You can use shoutrrr generic webhook support to send watchtower notifications to your ntfy topic.

Example docker-compose.yml:

    image: containrrr/watchtower

Or, if you only want to send notifications using shoutrrr:

shoutrrr send -u "generic+" -m "testMessage"