Keeping your VPS running smoothly isn’t just about deploying code and hoping for the best. Servers can run out of disk space, spike in CPU usage, or silently go down especially when you’re not watching. For solo developers, startups, and small teams, full-scale monitoring tools can feel heavy, expensive, or overkill.
That’s where a simple but powerful approach comes in: Cron jobs + Telegram alerts.
In this guide, I’ll show you how to monitor your VPS using lightweight Bash scripts scheduled with cron, and receive real-time alerts directly on Telegram. No complicated dashboards, no third-party monitoring bills just practical, reliable monitoring you fully control.
Why Monitor Your VPS in the First Place?
A VPS is usually responsible for running critical workloads: APIs, web apps, background workers, databases, or cron jobs themselves. Without monitoring, issues often go unnoticed until users complain or even worse, data is lost.
Proper VPS monitoring helps you:
- Detect high CPU or memory usage early
- Avoid disk space running out
- Know when services crash
- React fast before downtime escalates
- Sleep better knowing your server is being watched
And the good news? You can achieve this with tools already available on almost every Linux server.
Why Use Cron + Telegram for VPS Monitoring?
There are many monitoring solutions available, but this setup goes well because it’s:
- Lightweight – No extra agents or services running constantly
- Free – Telegram bots cost nothing
- Simple – Bash + cron is universally available
- Instant – Alerts arrive directly on your phone
- Customizable – You monitor exactly what matters to you
This makes it perfect for developers, sysadmins, and DevOps engineers who want control without complexity.
What You’ll Need Before Starting
Before setting things up, make sure you have:
- A Linux-based VPS (Ubuntu, Debian, CentOS, etc.)
- SSH access to the server
- Basic knowledge of Bash and cron
- A Telegram account
That’s it.
Step 1: Create a Telegram Bot
Telegram bots are how your server will send messages to you.
- Open Telegram and search for @BotFather
- Start a chat and run
/start
- Create a new bot using
/newbot
- Copy the Bot Token you receive
Next, get your Chat ID:
- Start a chat with your new bot
- Visit the Telegram API
getUpdates endpoint (or use a bot like @userinfobot)
- Copy your numeric chat ID
You’ll need both values later.
Step 2: Write a Basic Telegram Alert Script
Create a Bash script on your VPS:
nano /usr/local/bin/telegram_alert.sh
Add the following:
#!/bin/bash
BOT_TOKEN="YOUR_BOT_TOKEN"
CHAT_ID="YOUR_CHAT_ID"
MESSAGE="$1"
curl -s -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \
-d chat_id="$CHAT_ID" \
-d text="$MESSAGE"
Make it executable:
chmod +x /usr/local/bin/telegram_alert.sh
This script will be reused for all alerts.
Step 3: Monitor Disk Usage
Running out of disk space is one of the most common VPS killers.
Create a disk monitoring script:
nano /usr/local/bin/disk_monitor.sh
#!/bin/bash
THRESHOLD=80
USAGE=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')
if [ "$USAGE" -ge "$THRESHOLD" ]; then
/usr/local/bin/telegram_alert.sh "⚠️ VPS Alert: Disk usage is at ${USAGE}%"
fi
Make it executable:
chmod +x /usr/local/bin/disk_monitor.sh
Step 4: Monitor CPU Load
High CPU usage can signal runaway processes or attacks.
nano /usr/local/bin/cpu_monitor.sh
#!/bin/bash
LOAD=$(awk '{print int($1)}' /proc/loadavg)
THRESHOLD=4
if [ "$LOAD" -ge "$THRESHOLD" ]; then
/usr/local/bin/telegram_alert.sh " VPS Alert: High CPU load detected (Load: $LOAD)"
fi
Step 5: Monitor Memory Usage
Memory exhaustion can crash services silently.
nano /usr/local/bin/memory_monitor.sh
#!/bin/bash
USED=$(free | awk '/Mem/ {printf("%.0f"), $3/$2 * 100}')
THRESHOLD=80
if [ "$USED" -ge "$THRESHOLD" ]; then
/usr/local/bin/telegram_alert.sh " VPS Alert: Memory usage is at ${USED}%"
fi
Step 6: Schedule Everything With Cron
Now let cron do the work.
Edit your crontab:
crontab -e
Add:
*/5 * * * * /usr/local/bin/disk_monitor.sh
*/5 * * * * /usr/local/bin/cpu_monitor.sh
*/5 * * * * /usr/local/bin/memory_monitor.sh
This checks your VPS every 5 minutes and sends alerts only when thresholds are exceeded.
Best Practices for VPS Monitoring With Cron
To keep things clean and reliable:
- Log outputs to files for debugging
- Avoid alert spam—use sensible thresholds
- Test scripts manually before scheduling
- Secure your bot token (don’t commit it to Git)
- Extend monitoring gradually (services, uptime, network)
What Else Can You Monitor?
Once the basics are working, you can easily expand:
- Nginx/Apache service status
- MySQL/PostgreSQL uptime
- Docker container health
- SSL certificate expiry
- Failed login attempts
- Custom application health checks
The same Telegram alert script can handle all of it.
Conclusion: Simple Monitoring That Actually Works
You don’t need complex dashboards or expensive SaaS tools to keep an eye on your VPS. With cron jobs and Telegram alerts, you get:
- Real-time notifications
- Full control over monitoring logic
- Zero recurring costs
- A setup that scales with your needs
This approach is especially powerful for developers who enjoy understanding and owning their infrastructure.