Automated Server Log Cleanup via Email Alerts & SSH (Nginx/Docker)
Monitors IMAP emails for disk usage alerts >80%, extracts server IP, SSH connects, and purges Nginx, PM2, Docker, and system logs to reclaim space automatically.
This n8n workflow automates server maintenance by watching for email alerts on high disk utilization (over 80%). Upon receiving an alert, it parses the email content to extract the affected server's IP address, prepares SSH credentials and log paths, then securely logs in via SSH to execute targeted cleanup commands. Logs from Nginx access/error files, PM2 processes, Docker containers, and standard system directories (like /var/log) are safely rotated or deleted, preventing disk outages without manual intervention.
Key benefits include proactive disk space management, reducing downtime risks for production servers, and saving hours of manual sysadmin work. It's ideal for teams managing multiple VPS, cloud instances, or Dockerized apps where log bloat is common. The workflow handles unseen emails with 'disk' in the subject, ensuring reliable triggering.
Use cases span DevOps, hosting providers, and web agencies running Nginx/PM2 stacks. Customize by adjusting log paths in the 'Prepare SSH Variables' node or adding retention policies. Prerequisites: IMAP email access for alerts and SSH keys/passwords configured in n8n. Test with mock emails to validate IP extraction and cleanup before production.
New buyers can create an account from the cart to unlock a controlled $10 first-purchase credit on eligible orders of $25+.
Secure checkout powered by Stripe
Support
How to import this workflow into n8n
- 1Purchase or download the workflow to get the n8n workflow JSON file.
- 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
- 3Open each node marked with a credential warning and connect your own accounts and API keys.
- 4Run the workflow once manually to verify the data flow, then toggle it to Active.
Related Finance & Accounting workflows
- Automate Invoice Creation and Delivery with AI$9.99
- Automated Multi-Modal Expense Tracking via Telegram$24.99
- Automate Invoice Processing and Notifications with AI and Google Drive$14.99
- Automate Invoice Processing from Telegram to SAP with OCR and Google Sheets$14.99
- Automate Invoice Processing and Validation with OCR, AI, and Google Sheets$14.99
- Compare Multi-Period Financial Data from Google Sheets with DeepSeek AI Analysis$14.99
More from Arjun Radu
Need this deployed? We'll set it up for you.
Our automation experts deploy this workflow in your stack, connect your accounts, and verify it works — or build a custom solution from scratch.