Cron

HN Marketing Digest

Automatically fetch and filter Hacker News for marketing-related stories. Run it as a cron job in a Mags sandbox, or check the live feed below.

Preview Shell
$ sh hn-marketing.sh
=== HN Marketing Digest ===
Fetching top stories from Hacker News...

[1] Why SEO is dead in 2025
    Score: 342 | Link: https://...
    HN: https://news.ycombinator.com/...

Found 3 marketing-related stories.

Runs with just curl and jq on Alpine.

Recipe

Set up the cron job in 3 steps.

1 Upload script and install dependencies

Upload the shell script to a persistent workspace and install curl + jq.

mags run -f cookbook/hn-marketing.sh -w hn-digest \
  'cp hn-marketing.sh /root/ && chmod +x /root/hn-marketing.sh && apk add -q curl jq && echo "Setup complete"'

2 Test run it manually

Verify the script works before scheduling.

mags run -w hn-digest 'sh /root/hn-marketing.sh'

3 Activate the cron job

Schedule the digest to run every 2 hours.

mags cron add --name "hn-marketing" --schedule "0 */2 * * *" -w hn-digest \
  'sh /root/hn-marketing.sh'

Check cron status any time with mags cron list.

Script

The full shell script.

hn-marketing.sh

#!/bin/sh
# hn-marketing.sh — Fetch top HN stories and filter for marketing-related content
# Dependencies: curl, jq (install with: apk add -q curl jq)

set -e

KEYWORDS='marketing|growth hack|SEO|advertising|branding|brand strategy|content strategy|content marketing|acquisition|retention|funnel|conversion|GTM|go-to-market|product.led|newsletter|copywriting|social media|influencer|public relations|DTC|B2B marketing|B2C|demand gen|lead gen|campaign'

echo "=== HN Marketing Digest ==="
echo "Fetching top stories from Hacker News..."
echo ""

IDS=$(curl -sf "https://hacker-news.firebaseio.com/v0/topstories.json" | jq -r '.[0:100] | .[]')

if [ -z "$IDS" ]; then
  echo "Error: could not fetch story IDs"
  exit 1
fi

COUNT=0

for ID in $IDS; do
  ITEM=$(curl -sf "https://hacker-news.firebaseio.com/v0/item/${ID}.json")
  TITLE=$(echo "$ITEM" | jq -r '.title // empty')

  if [ -z "$TITLE" ]; then
    continue
  fi

  MATCH=$(echo "$TITLE" | grep -iE "$KEYWORDS" || true)

  if [ -n "$MATCH" ]; then
    URL=$(echo "$ITEM" | jq -r '.url // "https://news.ycombinator.com/item?id='"$ID"'"')
    SCORE=$(echo "$ITEM" | jq -r '.score // 0')
    TIME=$(echo "$ITEM" | jq -r '.time // 0')
    COUNT=$((COUNT + 1))

    echo "[$COUNT] $TITLE"
    echo "    Score: $SCORE | Link: $URL"
    echo "    HN: https://news.ycombinator.com/item?id=$ID"
    echo ""
  fi
done

if [ "$COUNT" -eq 0 ]; then
  echo "No marketing-related stories found in the current top 100."
else
  echo "---"
  echo "Found $COUNT marketing-related stories."
fi

Live feed

Marketing stories on HN right now.

Loading...
Fetching stories from Hacker News...