Untitled

atyh

18. September 2025September 18, 2025 · 3 Min. Lesezeit3 min read

Scheduled notes with Posix shell

I like simple, text based, unix ways of doing things. I dont like over-engineered solutions to simple puzzles, that try to take into account 1000 different use cases. I realize they are needed out there in the world, but in my world they are less needed. So this is my personal unixy way to do scheduled notes in nostr.

Requirements:

nak, a unix shell, Vi, rsync, cron, your nsec in hex format.

Caveats:

This is simple, designed for a single usecase. Because my laptop is only on when im using it, once composed, notes are rsynced to a vps, where a cronjob runs a script every minute, scanning a directory, looking for a current date and time match. If it finds one, it uses nak to send that note to relays specified in the script. Thats it. This way, I can schedule for a 24h window. It is helpful, if you are going to use a vps, to make sure the time locale on your vps is the same as your home computer, as the times wont match if they arent, and the scheduled notes will post at whackadoodle times. I played around with converting to unix time stamps, but it started to feel bloaty and un-neccesary, so this way works. The file name will look like 2025-09-17-1530. Simple.

Three scripts are used:

composing script:


#!/bin/sh

cal
echo "Enter a future date and time (e.g., '2025-09-20 15:30'):"
read input

# use gnu date from coreutils for -d on BSD. 
# date util should just work on linux
timestamp=$(date -d "$input" +%F-%H%M 2>/dev/null)

if [ -z "$timestamp" ]; then
  echo "Invalid date format. Try again."
  exit 1
fi

vi ~/rsync/nsched/"$timestamp"


sending script:


#!/bin/sh
# send scheduled nostr notes to vps
# of course, change to match your directories and server

rsync -authP ~/rsync/nsched/ atyh.net:~/rsync/nsched/

posting script, run as a cronjob:


#!/bin/sh
# cron script to check scheduled nostr note dir

(set -- \
    "wot.sudocarlos.com" \
    "wheat.happytavern.co" \
    "relay.mostr.pub" \
    "nostrelites.org" \
    "wot.sovbit.host"

# location of your sec key in hex. set appropriate permissions.
sec=$(<"/home/atyh/location/of/your/secret-key/in/hex-format")

sdir="/home/atyh/rsync/nsched"
stime=$(date +%F-%H%M)
note="$sdir/$stime"
pnote="$sdir/sent-$stime"


if [ -f "$note" ]; then
        nak event --sec $sec -c "$(<"$note")" "$@"
        mv $note $pnote
else
        exit 0
fi)

The post script is run in a subshell because posix cant define arrays explicitly, so using the set -- hack. Dont want a bunch of polution in $1, $2, etc, so run as a subshell.

If any of this nerdy nonsense makes sense to you, then youll know how to set a cron job to run every minute on the poster script.

Once everything is set up, all you have to do is run the first script locally, enter the date and time, :wq the note when its done, and run the rsync script. Your note will post at the scheduled time, and be renamed to sent-(date/time)

<3

Written by

Comments

No comments yet. Start the conversation.