Use this robust n8n workflow template to automate server log cleanup (Nginx, Docker, system logs) instantly upon receiving disk utilization alert emails, leveraging the power of the SSH n8n node.
Download this n8n workflow template and start using it instantly.
DevOps engineers tired of manual server cleanups.
System administrators managing multiple self-hosted applications (Docker, Nginx).
Users seeking reliable n8n templates for incident response automation.
Anyone needing an automated, reactive solution for disk space management.
Server disk space exhaustion is a leading cause of unexpected service downtime, often caused by runaway application logs, outdated system packages, or large Docker caches. Manually responding to every 'disk full' alert is inefficient and reactive.
This specialized n8n workflow transforms a passive email alert into an active remediation action. By using a specific n8n trigger tied to IMAP alerts, the system automatically identifies the affected server and executes a detailed sequence of cleanup commands (including purging Nginx logs, running journalctl --vacuum, and pruning Docker builders) via the SSH n8n node. This particular n8n workflow is a crucial tool for maintaining system health and ensuring high availability.
This automation functions as a reactive incident management system, starting with a precise n8n trigger.
Check Disk Alert Emails n8n node, which acts as the primary n8n trigger. It monitors an IMAP inbox for new, unseen emails where the subject contains the keyword 'disk'.Extract Server IP from Email custom code n8n node executes a regular expression to parse the email subject line. This code is crucial for isolating the exact IP address of the server that needs attention.Prepare SSH Variables n8n node standardizes the necessary inputs (username, password, and the extracted server_ip) for the subsequent remote command execution.Run Log Cleanup Commands via SSH n8n node. It securely connects to the target server using the supplied credentials and executes a powerful chained cleanup command. This command sequence is designed to free up space by cleaning system logs, Nginx/Apache logs, running apt-get clean, and pruning cached Docker images, resolving the high disk utilization alert automatically.To deploy and use this powerful n8n workflow, follow these steps:
Check Disk Alert Emails n8n trigger node with your IMAP service credentials. Ensure the connection is authorized to read the inbox where your monitoring system sends disk alerts.SSH Password credential used by the Run Log Cleanup Commands via SSH n8n node. This needs access to the jump host or server specified in the command structure.Prepare SSH Variables n8n node. Replace the placeholder values for pwd (the sudo password) and server_user with the credentials required to execute privileged commands on the target servers.This n8n workflow utilizes several key n8n node components for data extraction and secure execution:
Check Disk Alert Emails (IMAP Trigger): This is the starting n8n trigger. Its function is to poll an inbox for new, unread emails (UNSEEN) specifically matching the subject filter containing disk. This ensures the n8n workflow only runs when a critical alert is received.
Extract Server IP from Email (Code Node): This custom code n8n node processes the incoming email subject line. It uses regex (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):9100 to reliably extract the server's IP address, which is vital for targeting the cleanup action.
Prepare SSH Variables (Set Node): This n8n node standardizes inputs. It captures the extracted server_ip from the previous step and sets static variables for the SSH command (like the user and password required for sudo).
Run Log Cleanup Commands via SSH (SSH Node): This is the action n8n node. It executes a complex, single command over SSH designed for system cleanup. Key parts of the command include:
Using echo '{{ $json.pwd }}' | sudo -S to pass the password for elevated privileges.
Targeted removal of compressed and old logs (rm -rf /var/log/.gz, .1, Nginx/Apache logs).
System maintenance (journalctl --vacuum-size=200M, apt-get clean, autoclean, autoremove).
Docker resource recovery (docker builder prune -af and status check docker system df).
Use this powerful n8n workflow to run scheduled SSH server checks, analyze raw data using GPT-4, and automatically generate structured email alerts for proactive DevOps monitoring. Find more n8n templates.

Analyze Sophos security alerts automatically using this n8n workflow. It extracts IoCs, queries VirusTotal, and uses the Gemini AI agent to generate summaries and mitigation steps, alerting SOC teams via Telegram. Essential n8n templates for security.

Use this robust n8n workflow to generate personalized sales proposals (summary, one-pager, draft) via GPT-4o, manage leads in Google Sheets, and store files in Google Drive.

Use this powerful n8n workflow template to automatically detect and report abandoned shopping carts tracked by Razorpay directly to Telegram, ensuring rapid follow-up on potential sales.

Use this powerful n8n workflow to automate Shopify abandoned cart recovery. Schedule checks, verify customer phone numbers with Rapiwa, and send personalized WhatsApp messages, logging results in Google Sheets.

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.







































