⚙️ Automated server log cleanup via email alerts with SSH - Nginx, Docker, System

1,243 views · ⚙️ DevOps & CI/CD

Description

This n8n workflow monitors email alerts for disk utilization exceeding 80%, extracts the server IP, logs into the server, and purges logs from Nginx, PM2, Docker, and system files to clear disk space.

Key Insights

Workflow Process

  1. Initiate the workflow with the Check Disk Alert Emails node when an email triggers on high disk usage.
  2. Parse the email to extract the server IP using the Extract Server IP from Email node.
  3. Set up SSH credentials and paths manually with the Prepare SSH Variables node.
  4. Execute cleanup commands to delete logs from Nginx, PM2, Docker, and system files using the Run LogCleanup Commands via SSH node.

Usage Guide

Prerequisites

Customization Options

Modify the Prepare SSH Variables node to target specific log directories or adjust cleanup commands for different server setups.

🔗 Nodes Used

Email Trigger (IMAP), SSH

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup