Docs / Monitoring & Logging / How to Set Up Email Alerts for Server Issues

How to Set Up Email Alerts for Server Issues

By Admin · Feb 25, 2026 · Updated Apr 25, 2026 · 483 views · 1 min read

Get notified when your server has problems so you can respond quickly.

Install Mail Utilities

apt install mailutils -y

Disk Space Alert Script

#!/bin/bash\nUSAGE=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')\nif [ "$USAGE" -gt 85 ]; then\n    echo "Disk usage is at ${USAGE}% on $(hostname)" | mail -s "Disk Alert" admin@example.com\nfi

Schedule with Cron

*/30 * * * * /usr/local/bin/disk-alert.sh

Memory Alert

#!/bin/bash\nAVAIL=$(free -m | awk '/Mem/ {print $7}')\nif [ "$AVAIL" -lt 100 ]; then\n    echo "Available memory is ${AVAIL}MB on $(hostname)" | mail -s "Memory Alert" admin@example.com\nfi

Was this article helpful?