Automated Server Log Cleanup via Email Alerts with SSH - Nginx, Docker, System
Last edited 58 days ago
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
- Ensure email alerts are consistently formatted with server IP details.
- SSH access must be properly configured to avoid authentication failures.
Workflow Process
- Initiate the workflow with the
Check Disk Alert Emailsnode when an email triggers on high disk usage. - Parse the email to extract the server IP using the
Extract Server IP from Emailnode. - Set up SSH credentials and paths manually with the
Prepare SSH Variablesnode. - Execute cleanup commands to delete logs from Nginx, PM2, Docker, and system files using the
Run LogCleanup Commands via SSHnode.
Usage Guide
- Import the workflow into n8n and configure email and SSH credentials.
- Test with a sample email alert to verify IP extraction and log deletion.
Prerequisites
- Email service (e.g., IMAP or API) for alert monitoring
- SSH access with valid credentials
Customization Options
Modify the Prepare SSH Variables node to target specific log directories or adjust cleanup commands for different server setups.
You may also like
New to n8n?
Need help building new n8n workflows? Process automation for you or your company will save you time and money, and it's completely free!





