Cron / VPS

Cron job gagal atau VPS down? Kirim alert ke ponsel.

Backup, SSL, disk space, dan health check harus memberi tahu tanpa membuka token atau history.

Short answer

Gunakan shell wrapper untuk menjalankan job, menangkap stderr, lalu mengirim ringkasan singkat dengan nerve send saat gagal.

Jangan kirim full logs ke ponsel. Kirim job name, host, exit code, timestamp, dan link ke dashboard atau runbook.

Wrapper script

#!/usr/bin/env sh
set -u

export NERVE_DSN="nerve://TOKEN:[email protected]"
LOG="/tmp/backup-cron.log"

if ! /opt/backup.sh >"$LOG" 2>&1; then
  {
    echo "cron failed: backup"
    echo "host=$(hostname)"
    echo "time=$(date -Is)"
    tail -20 "$LOG"
  } | nerve send --severity critical
fi

Crontab

0 2 * * * /usr/local/bin/backup-with-alert.sh

VPS and server checks

The same pattern works for disk space checks, SSL expiry checks, database backup jobs, systemd service health, and small VPS monitoring scripts.

Noise control

Add a cooldown if a job can fail repeatedly. One useful phone alert is better than fifty duplicate notifications while the same service is down.

Security boundary

Send-only secretSender DSN mengirim encrypted signals ke satu pipe. Ia tidak bisa membaca history, decrypt messages, atau menjalankan commands.
No agent tokenUntuk alerts biasa kamu tidak perlu agent token. Gunakan agent hanya pada mesin tepercaya untuk signed bounded actions.
Safe summarySend host, job name, exit code, and a short tail. Keep credentials out of alerts.

FAQ

Bagaimana mengirim alert GitHub Actions ke ponsel?

Tambahkan step nerve send dengan if: failure() dan simpan NERVE_DSN sebagai GitHub Actions secret.

Apakah sender DSN bisa membaca alert lama?

Tidak. Sender DSN hanya bisa mengirim encrypted signals ke satu pipe.

Apakah perlu menjalankan agent untuk menerima alerts?

Tidak. Agent opsional dan dipakai untuk signed actions di mesin tepercaya.

Related