Email alerts catch problems before users do. A small script plus cron covers basic thresholds without a full monitoring stack.
Steps
Install a local mail client (configure SMTP/relay for your provider):
sudo apt updatesudo apt install -y mailutilsCreate a script that emails when root disk exceeds 85%:
sudo tee /usr/local/bin/disk-alert.sh >/dev/null <<'EOF'#!/bin/bashTHRESHOLD=85USAGE=$(df -P / | awk 'NR==2 {gsub(/%/,"",$5); print $5}')HOST=$(hostname -f)if [ "$USAGE" -ge "$THRESHOLD" ]; then echo "Disk ${USAGE}% on ${HOST}" | mail -s "[ALERT] disk ${HOST}" [email protected]sudo chmod +x /usr/local/bin/disk-alert.shRun it once and schedule every 5 minutes:
sudo /usr/local/bin/disk-alert.sh(sudo crontab -l 2>/dev/null; echo "*/5 * * * * /usr/local/bin/disk-alert.sh") | sudo crontab -Confirm the cron line:
sudo crontab -l
Tips
- Replace
[email protected]and configure a real SMTP/relay or mail will not leave the host. - Reuse the same pattern for CPU/RAM with
loadavgorfree.
ext step
Monitor a production VPS from day one: Deploy your Cloud VPS.