Short answer
Dùng shell wrapper để chạy job, capture stderr, và gửi summary ngắn bằng nerve send khi job fail.
Đừng gửi full logs tới điện thoại. Gửi job name, host, exit code, timestamp và link dashboard hoặc runbook là đủ.
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
FAQ
Làm sao gửi GitHub Actions alert tới điện thoại?
Thêm step nerve send với if: failure() và lưu NERVE_DSN như GitHub Actions secret.
Sender DSN có đọc được alert cũ không?
Không. Sender DSN chỉ gửi encrypted signals vào một pipe.
Có cần chạy agent để nhận alerts không?
Không. Agent là tùy chọn cho signed actions trên máy tin tưởng.