8
n8n 한국어amn8n.com

자동화 실행 정리 시스템

중급

이것은DevOps분야의자동화 워크플로우로, 12개의 노드를 포함합니다.주로 N8n, Set, Code, ScheduleTrigger 등의 노드를 사용하며. n8n API와 사용자 정의 보존 규칙을 사용한 자동 실행 정리 시스템

사전 요구사항
  • 특별한 사전 요구사항 없이 가져와 바로 사용 가능합니다

카테고리

워크플로우 미리보기
노드 연결 관계를 시각적으로 표시하며, 확대/축소 및 이동을 지원합니다
워크플로우 내보내기
다음 JSON 구성을 복사하여 n8n에 가져오면 이 워크플로우를 사용할 수 있습니다
{
  "meta": {
    "instanceId": "0a82a9d5784b67ad963ceff89283b2e40cb771be10fe58ba2682f3598a37c6e1",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "fc2eb1d2-8c2e-4956-a084-ef685652cdbd",
      "name": "스케줄 트리거",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        320,
        -32
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 2
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f528c67c-0077-4d84-a756-5b9020b838d8",
      "name": "다수 실행 가져오기",
      "type": "n8n-nodes-base.n8n",
      "position": [
        816,
        -32
      ],
      "parameters": {
        "limit": 250,
        "filters": {},
        "options": {
          "activeWorkflows": false
        },
        "resource": "execution",
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "id": "VSxAuLMW3kDlXjYA",
          "name": "EMPTY"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9e3f98f2-f2f6-4d15-8858-1dacc46582a0",
      "name": "코드",
      "type": "n8n-nodes-base.code",
      "position": [
        1824,
        -32
      ],
      "parameters": {
        "jsCode": "const executionsToKeep = $input.first().json.executionsToKeep ?? 10;\n\n// Filtrar ejecuciones válidas (con workflowId y startedAt)\nconst validExecutions = items.filter(item =>\n  item.json.workflowId && item.json.startedAt\n);\n\n// Agrupar por workflowId\nconst grouped = {};\nfor (const item of validExecutions) {\n  const wfId = item.json.workflowId;\n  if (!grouped[wfId]) grouped[wfId] = [];\n  grouped[wfId].push(item);\n}\n\n// Ordenar por startedAt descendente (más reciente primero)\nfor (const wfId in grouped) {\n  grouped[wfId].sort((a, b) =>\n    new Date(b.json.startedAt) - new Date(a.json.startedAt)\n  );\n}\n\n// Obtener ejecuciones a eliminar\nlet toDelete = [];\nfor (const wfId in grouped) {\n  const executions = grouped[wfId];\n  if (executions.length > executionsToKeep) {\n    toDelete = toDelete.concat(executions.slice(executionsToKeep));\n  }\n}\n\nreturn toDelete;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "68e8939a-10f0-4a65-a56c-5f643d2dceec",
      "name": "실행 삭제",
      "type": "n8n-nodes-base.n8n",
      "position": [
        2304,
        -32
      ],
      "parameters": {
        "resource": "execution",
        "operation": "delete",
        "executionId": "={{ $json.id }}",
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "id": "VSxAuLMW3kDlXjYA",
          "name": "EMPTY"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c59692b1-8dc8-44f8-bd31-dcc3898a2978",
      "name": "스티키 노트",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        -880
      ],
      "parameters": {
        "width": 896,
        "height": 1680,
        "content": "# 🧹 Automatically Clean Up Old Executions in n8n (Keep Only the Most Recent Per Workflow)\nMake your n8n instance faster, cleaner, and more efficient by deleting old workflow executions — while keeping only the most recent ones you actually need. Whether you're using n8n Cloud or self-hosted, this lightweight workflow helps reduce database/storage usage and improves UI responsiveness, using only official n8n nodes.\n\n## 🔍 Description\nAutomatically clean up old executions in your n8n instance using only official nodes — no external database queries required. Whether you're on the Cloud version or running self-hosted, this workflow helps you optimize performance and keep your instance tidy by maintaining only the most recent executions per workflow.\n\nIdeal for users managing dozens or hundreds of workflows, this solution reduces storage usage and improves the responsiveness of the n8n UI, especially in environments where execution logs can accumulate quickly.\n\n✅ What It Does\n* Retrieves up to 250 recent executions across all workflows\n* Groups executions by workflow\n* Keeps only the most recent N executions per workflow (value  is configurable)\n* Deletes all older executions (regardless of their status: success, error, etc.)\n* Works entirely with native n8n nodes — no external database access required\n* Optionally: set the number of executions to keep as 0 to delete all past executions from your instance in a single run\n\n## 🛠️ How to Set Up\n🔑 Create a Personal API Key in your n8n instance:\nGo to Settings → API Keys → Create a new key\n\n🔧 Create a new n8n API Credential (used by both nodes):\nIn your n8n credentials panel:\n\nName: anything you like (e.g., “Internal API Access”)\n\nAPI Key: paste the Personal API Key you just created\n\nBase URL: your full n8n instance URL with the /api/v1 path, e.g.\nhttps://your-n8n-instance.com/api/v1\n\n✅ Use this credential in both:\n\nThe Get Many Executions node (to fetch recent executions)\n\nThe Delete Many Executions node (to remove outdated executions)\n\n🧩 In the “Set Executions to Keep” node:\n\nEdit the variable executionsToKeep and set the number of most recent executions to retain per workflow (e.g. 10)\n\nTip: Set it to 0 to delete all executions\n\n📦 Note: The “Get Many Executions” node will retrieve up to 250 executions per run — this is the maximum allowed by the n8n API.\n\n🧠 No further setup is required — the filtering and grouping logic is handled inside the Code Node automatically.\n\n\n## 🧪 Included Nodes Overview\n🕒 Schedule Trigger → Set to run daily, weekly, etc.\n\n📥 Get Many Executions → Fetches past executions via n8n API\n\n🛠️ Set Executions to Keep → Set how many recent ones to keep\n\n🧠 Code Node → Filters out executions to delete per workflow\n\n🗑️ Delete Executions → Deletes outdated executions\n\n## 💡 Why Use This?\nReduce clutter and improve performance in your n8n instance\n\nMaintain execution logs only when they’re useful\n\nAvoid bloating your storage or database with obsolete data\n\nCompatible with both n8n Cloud and self-hosted setups\n\nUses only official, supported n8n nodes — no SQL, no extra setup\n\n🔒 This workflow modifies and deletes execution data. Always review and test it first on a staging instance or on a limited set of workflows before using it in production.\n\n\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8ecf0fc5-9917-474c-b3f2-32d45ecf7059",
      "name": "보관 실행 설정",
      "type": "n8n-nodes-base.set",
      "position": [
        1328,
        -32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a7f3a2de-0606-434c-8a81-4bf64e766899",
              "name": "executionsToKeep",
              "type": "number",
              "value": 10
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "a249ad6e-6abc-42b8-a272-506c0f3f76a6",
      "name": "스티키 노트1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        -720
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 1520,
        "content": "# 🕒 Schedule Trigger\nThis node defines how often the cleanup workflow should run. You can schedule it to execute daily, weekly, or at any custom interval.\n[to learn more about Schedule Trigger node see the documentation](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.scheduleTrigger)"
      },
      "typeVersion": 1
    },
    {
      "id": "7f7c076d-2bb6-4cef-88c2-6fef8e22f4e1",
      "name": "스티키 노트2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        -720
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 1520,
        "content": "# 📥 Get Many Executions\nFetches up to 250 of the most recent executions from your n8n instance. It includes data like workflow ID, execution status, and timestamps.\n[to learn more about Get Many Executions node see the documentation](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.n8n/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.n8n#get-many-executions)"
      },
      "typeVersion": 1
    },
    {
      "id": "b2be8559-6cbd-4778-8830-4fa467efe363",
      "name": "스티키 노트3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        -720
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 1520,
        "content": "# 🛠️ Set Executions to Keep\nThis node defines how many of the most recent executions per workflow should be kept. You can easily adjust the executionsToKeep variable — set it to 10, 5, or 0 to delete all.\n[to learn more about Set node see the documentation](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.set)"
      },
      "typeVersion": 1
    },
    {
      "id": "f31f51a1-70ba-46f5-adbb-4752b6c6d2c8",
      "name": "스티키 노트4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1616,
        -720
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 1520,
        "content": "# 🧠 Code Node (Filter Executions to Delete)\nThis node processes the list of executions, groups them by workflow ID, sorts each group by most recent first, and filters out the oldest executions beyond the number you want to keep. Running executions are automatically excluded.\n[o learn more about Code node see the documentation](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.code)"
      },
      "typeVersion": 1
    },
    {
      "id": "a7b5add2-eab2-4b79-b7d3-6e84fb4dc118",
      "name": "스티키 노트5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        -720
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 1520,
        "content": "# 🗑️ Delete Many Executions\nDeletes the selected executions using the official n8n API. It works in bulk and uses the same API credential as the \"Get Many Executions\" node.\n[to learn more about Delete Executions node see the documentation](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.n8n/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.n8n#delete-execution)"
      },
      "typeVersion": 1
    },
    {
      "id": "00e57fb6-961a-4e85-81c6-2de04f301a93",
      "name": "스티키 노트6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        -880
      ],
      "parameters": {
        "color": 3,
        "width": 2432,
        "height": 128,
        "content": "# ❗ This workflow deletes data. Always test in staging before enabling in production.  "
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "9e3f98f2-f2f6-4d15-8858-1dacc46582a0": {
      "main": [
        [
          {
            "node": "68e8939a-10f0-4a65-a56c-5f643d2dceec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fc2eb1d2-8c2e-4956-a084-ef685652cdbd": {
      "main": [
        [
          {
            "node": "f528c67c-0077-4d84-a756-5b9020b838d8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "68e8939a-10f0-4a65-a56c-5f643d2dceec": {
      "main": [
        []
      ]
    },
    "f528c67c-0077-4d84-a756-5b9020b838d8": {
      "main": [
        [
          {
            "node": "8ecf0fc5-9917-474c-b3f2-32d45ecf7059",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8ecf0fc5-9917-474c-b3f2-32d45ecf7059": {
      "main": [
        [
          {
            "node": "9e3f98f2-f2f6-4d15-8858-1dacc46582a0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
자주 묻는 질문

이 워크플로우를 어떻게 사용하나요?

위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.

이 워크플로우는 어떤 시나리오에 적합한가요?

중급 - 데브옵스

유료인가요?

이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.

워크플로우 정보
난이도
중급
노드 수12
카테고리1
노드 유형5
난이도 설명

일정 경험을 가진 사용자를 위한 6-15개 노드의 중간 복잡도 워크플로우

저자
Arlin Perez

Arlin Perez

@arlindeveloper

👋 Hi! I'm Arlin - a QA Engineer with 2 years of experience and a background in Dart & Flutter for mobile app development. ⚙️ I'm passionate about automation and love building efficient workflows using n8n. 📬 Reach out for any help with custom workflows

외부 링크
n8n.io에서 보기

이 워크플로우 공유

카테고리

카테고리: 34