Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

Build a daily email digest with cron and 6 lines of bash

DEV Community·Qasim Muhammad·28 days ago
#JUQKUkzd
#linux#bash#automation#fullscreen#nylas#email
Reading 0:00
15s threshold

Every product team rebuilds the same thing: a 7 AM email summarising what happened yesterday. Signups. Errors. New customers. Pipeline counts. Some teams use Looker. Some pay Zapier. Some have a sheet that nobody opens. The honest answer for most cases: 6 lines of bash, one cron entry, ship. What you need A Linux box (or macOS) with cron Whatever query speaks to your data (psql, mysql, an API) The Nylas CLI installed and authenticated brew install nylas/nylas-cli/nylas # or: curl -fsSL https://cli.nylas.com/install.sh | bash nylas auth config --api-key YOUR_KEY Enter fullscreen mode Exit fullscreen mode The script Save as /opt/scripts/digest.sh : #!/usr/bin/env bash set -euo pipefail SIGNUPS = $( psql -tA -h db.example.com -U readonly app -c "SELECT count(*) FROM users WHERE created_at > now() - interval '1 day'" ) ERRORS = $( psql -tA -h db.example.com -U readonly app -c "SELECT count(*) FROM events WHERE level='error' AND created_at > now() - interval '1 day'" ) REVENUE = $( psql -tA -h…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More