Skip to main content
Business Process Automation Scheduled

Manual Cron Automation Scheduled

1
14 downloads
15-45 minutes
🔌
4
Integrations
Intermediate
Complexity
🚀
Ready
To Deploy
Tested
& Verified

What's Included

📁 Files & Resources

  • Complete N8N workflow file
  • Setup & configuration guide
  • API credentials template
  • Troubleshooting guide

🎯 Support & Updates

  • 30-day email support
  • Free updates for 1 year
  • Community Discord access
  • Commercial license included

Agent Documentation

Standard

Manual Cron Automation Scheduled – Business Process Automation | Complete n8n Scheduled Guide (Intermediate)

This article provides a complete, practical walkthrough of the Manual Cron Automation Scheduled n8n agent. It connects HTTP Request, Webhook across approximately 1 node(s). Expect a Intermediate setup in 15-45 minutes. One‑time purchase: €29.

What This Agent Does

This agent orchestrates a reliable automation between HTTP Request, Webhook, handling triggers, data enrichment, and delivery with guardrails for errors and rate limits.

It streamlines multi‑step processes that would otherwise require manual exports, spreadsheet cleanup, and repeated API requests. By centralizing logic in n8n, it reduces context switching, lowers error rates, and ensures consistent results across teams.

Typical outcomes include faster lead handoffs, automated notifications, accurate data synchronization, and better visibility via execution logs and optional Slack/Email alerts.

How It Works

The workflow uses standard n8n building blocks like Webhook or Schedule triggers, HTTP Request for API calls, and control nodes (IF, Merge, Set) to validate inputs, branch on conditions, and format outputs. Retries and timeouts improve resilience, while credentials keep secrets safe.

Third‑Party Integrations

  • HTTP Request
  • Webhook

Import and Use in n8n

  1. Open n8n and create a new workflow or collection.
  2. Choose Import from File or Paste JSON.
  3. Paste the JSON below, then click Import.
  4. Show n8n JSON
    Title:
    Automating n8n Execution History Cleanup with MySQL and Cron Triggers
    
    Meta Description:
    Learn how to automate the purging of n8n execution history older than 30 days using a simple workflow that leverages MySQL and cron scheduling. Ideal for optimizing performance and managing database storage efficiently.
    
    Keywords:
    n8n workflow automation, MySQL query, purge execution history, cron job, database cleanup, n8n MySQL integration, data retention, automate n8n maintenance
    
    Third-Party APIs/Services Used:
    - MySQL (via n8n MySQL node)
    
    Article:
    
    Maintaining a clean and optimized database is crucial for the performance and sustainability of any long-running automation platform. For self-hosted users of n8n—a powerful open-source workflow automation tool—workflow execution data can accumulate and degrade system performance over time. Fortunately, n8n’s modular nature allows for the creation of efficient automated maintenance routines using its visual workflow builder.
    
    In this article, we’ll walk through a practical example of using a custom n8n workflow designed to automatically delete workflow execution history older than 30 days. This simple yet effective routine uses a combination of a manual trigger, a daily cron scheduler, and a direct query to a MySQL database to ensure that your system remains clean and efficient over the long term.
    
    Overview of the Workflow
    
    The featured workflow is called n8n_mysql_purge_history_greater_than_10_days, although, based on the actual query, it deletes data older than 30 days, suggesting the name could be updated for clarity. The workflow contains three nodes:
    
    1. Manual Trigger Node ("On clicking 'execute'")
    2. MySQL Node ("MySQL")
    3. Cron Node ("Cron")
    
    Let’s break down the purpose and configuration of each component.
    
    Manual Trigger: Testing the Cleanup on Demand
    
    The first node is a Manual Trigger which enables users to run the workflow on-demand. This is ideal for testing or for cases where an admin might want to verify the deletion process before scheduling it as a daily task.
    
    When the workflow is executed manually, it passes control directly to the MySQL Node, which performs the database cleanup operation.
    
    MySQL Node: The Heart of the Cleanup Logic
    
    The core functionality lies in the MySQL node, which executes a SQL query targeting the execution history of workflows.
    
    The query used is as follows:
    
    ```sql
    DELETE FROM execution_entity 
    WHERE DATE(stoppedAt) < DATE_SUB(CURDATE(), INTERVAL 30 DAY)
    ```
    
    This query instructs MySQL to remove all records from the execution_entity table where the stoppedAt date is more than 30 days old. execution_entity is the internal table where n8n stores metadata about completed workflow executions, including timestamps.
    
    This approach effectively maintains a rolling 30-day retention period for execution logs.
    
    It’s important to emphasize that this solution is safe only for users who are comfortable losing older execution history. If audit trails or long-term logging is required, consider exporting records to an external storage system before deletion.
    
    Cron Node: Automating the Cleanup at 7 AM Daily
    
    To make this operation automatic, the workflow includes a Cron node configured to trigger daily at 7:00 AM. When the time condition is met, the Cron node passes execution to the MySQL node, running the same purge query as would be executed manually.
    
    This ensures that the database cleanup happens reliably every day, removing any need for manual intervention.
    
    Benefits of This Workflow
    
    - Improved Performance: Clearing out old execution records can significantly speed up dashboard loading and searches.
    - Reduced Storage Use: Prevents the MySQL database from growing indefinitely.
    - Automation-Friendly: Uses built-in cron scheduling to run without human input.
    - Customizable: The number of days before deletion can be modified directly in the SQL query.
    
    Potential Enhancements
    
    While the current workflow is effective, here are a few ideas for expanding its functionality:
    - Add Logging: Use n8n’s built-in logging or notification nodes (e.g., Slack, Email) to send confirmation of deletion.
    - Make Retention Period Dynamic: Use environment variables or an n8n parameter node to define the number of days to retain dynamically.
    - Backup First: Chain a data export step to backup the old execution logs before deleting them.
    
    Conclusion
    
    With just three nodes, this n8n workflow provides a clean, efficient maintenance solution for self-hosted automation systems. By regularly purging execution history data older than 30 days, you ensure better performance and leaner storage needs.
    
    Whether you’re maintaining a single-user instance or managing a larger n8n deployment, automating database maintenance like this is a best practice that saves time and prevents future headaches. Thanks to n8n’s flexibility and low-code interface, even complex backend management tasks can be made routine with just a few minutes of setup.
    
    If you're looking to automate more of your maintenance or monitoring tasks, you might also explore n8n's integrations with alerting platforms, data validators, and cloud platforms. Because when maintenance is just another workflow, everything gets easier.
  5. Set credentials for each API node (keys, OAuth) in Credentials.
  6. Run a test via Execute Workflow. Inspect Run Data, then adjust parameters.
  7. Enable the workflow to run on schedule, webhook, or triggers as configured.

Tips: keep secrets in credentials, add retries and timeouts on HTTP nodes, implement error notifications, and paginate large API fetches.

Validation: use IF/Code nodes to sanitize inputs and guard against empty payloads.

Why Automate This with AI Agents

AI‑assisted automations offload repetitive, error‑prone tasks to a predictable workflow. Instead of manual copy‑paste and ad‑hoc scripts, your team gets a governed pipeline with versioned state, auditability, and observable runs.

n8n’s node graph makes data flow transparent while AI‑powered enrichment (classification, extraction, summarization) boosts throughput and consistency. Teams reclaim time, reduce operational costs, and standardize best practices without sacrificing flexibility.

Compared to one‑off integrations, an AI agent is easier to extend: swap APIs, add filters, or bolt on notifications without rewriting everything. You get reliability, control, and a faster path from idea to production.

Best Practices

  • Credentials: restrict scopes and rotate tokens regularly.
  • Resilience: configure retries, timeouts, and backoff for API nodes.
  • Data Quality: validate inputs; normalize fields early to reduce downstream branching.
  • Performance: batch records and paginate for large datasets.
  • Observability: add failure alerts (Email/Slack) and persistent logs for auditing.
  • Security: avoid sensitive data in logs; use environment variables and n8n credentials.

FAQs

Can I swap integrations later? Yes. Replace or add nodes and re‑map fields without rebuilding the whole flow.

How do I monitor failures? Use Execution logs and add notifications on the Error Trigger path.

Does it scale? Use queues, batching, and sub‑workflows to split responsibilities and control load.

Is my data safe? Keep secrets in Credentials, restrict token scopes, and review access logs.

Keywords: n8n, workflow automation, mysql query, purge execution history, cron job, database cleanup, n8n mysql integration, data retention, automate n8n maintenance, manual trigger, sql query, execution_entity, cron scheduling, dashboard loading, storage use, automation-friendly, logging, slack, email, dynamic retention, backup, enhancement, alerting platforms, data validators, cloud platforms

Integrations referenced: HTTP Request, Webhook

Complexity: Intermediate • Setup: 15-45 minutes • Price: €29

Requirements

N8N Version
v0.200.0 or higher required
API Access
Valid API keys for integrated services
Technical Skills
Basic understanding of automation workflows
One-time purchase
€29
Lifetime access • No subscription

Included in purchase:

  • Complete N8N workflow file
  • Setup & configuration guide
  • 30 days email support
  • Free updates for 1 year
  • Commercial license
Secure Payment
Instant Access
14
Downloads
1★
Rating
Intermediate
Level