Crontab not working properly

I am struggling with serring cron node. I would like to workflow be running every 5 minutes at 10 and 11 am so 10:00, 10:05 … 11:00, 11:05 … 11:55 and also via webhook

{
  "nodes": [
    {
      "parameters": {
        "url": "https://koronawirus-api.herokuapp.com/api/covid-vaccinations-tests/daily",
        "options": {}
      },
      "name": "Get data",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        160,
        480
      ]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": "51041012-9664-43f8-8237-b91d26f87ea9",
        "returnAll": true,
        "options": {
          "filter": {
            "multipleCondition": {
              "condition": {
                "and": [
                  {
                    "key": "Projekt|select",
                    "condition": "equals",
                    "selectValue": "Covid report"
                  },
                  {
                    "key": "Additional information|rich_text",
                    "condition": "equals",
                    "richTextValue": "={{$json[\"reportDate\"].substr(0,10)}}"
                  },
                  {
                    "key": "Return code|number",
                    "condition": "equals"
                  }
                ]
              }
            }
          }
        }
      },
      "name": "Check if already got",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 1,
      "position": [
        360,
        480
      ],
      "executeOnce": false,
      "alwaysOutputData": true,
      "credentials": {
        "notionApi": {
          "id": "1",
          "name": "[email protected]"
        }
      }
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": "51041012-9664-43f8-8237-b91d26f87ea9",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Name|title",
              "title": "=Coronavirus report from {{$node[\"Get data\"].json[\"reportDate\"].substr(0,10)}} pushed to discord server!"
            },
            {
              "key": "Additional information|rich_text",
              "textContent": "={{$node[\"Get data\"].json[\"reportDate\"].substr(0,10)}}"
            },
            {
              "key": "Projekt|select",
              "selectValue": "53bda0cd-99d6-4c98-a512-bff3c7c01176"
            },
            {
              "key": "Return code|number"
            }
          ]
        }
      },
      "name": "Log data",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 1,
      "position": [
        1280,
        480
      ],
      "credentials": {
        "notionApi": {
          "id": "1",
          "name": "[email protected]"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{Object.keys($node[\"Check if already got\"].json).length === 0 || $node[\"Webhook\"].json[\"headers\"][\"host\"].length > 0}}",
              "value2": true
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        560,
        480
      ]
    },
    {
      "parameters": {
        "imageTemplateId": "bb977b2b12f3186c",
        "jsonParameters": true,
        "overridesJson": "=[\n{\"name\": \"date\",\"text\": \"{{$node[\"Get data\"].json[\"reportDate\"].substr(0,10)}}\"},\n\n{\"name\": \"11\",\"text\": \"{{$node[\"Get data\"].json[\"today\"][\"infections\"][\"newInfections\"]}}\"},\n{\"name\": \"21\",\"text\": \"{{$node[\"Get data\"].json[\"general\"][\"infections\"][\"infections\"]}}\"},\n{\"name\": \"12\",\"text\": \"{{$node[\"Get data\"].json[\"today\"][\"infections\"][\"newDeaths\"]}}\"},\n{\"name\": \"22\",\"text\": \"{{$node[\"Get data\"].json[\"general\"][\"infections\"][\"deaths\"]}}\"},\n{\"name\": \"13\",\"text\": \"{{$node[\"Get data\"].json[\"today\"][\"vaccinations\"][\"firstDoses\"]}}\"},\n{\"name\": \"23\",\"text\": \"{{$node[\"Get data\"].json[\"general\"][\"vaccinations\"][\"firstDoses\"]}}\"},\n{\"name\": \"14\",\"text\": \"{{$node[\"Get data\"].json[\"today\"][\"vaccinations\"][\"secondDoses\"]}}\"},\n{\"name\": \"24\",\"text\": \"{{$node[\"Get data\"].json[\"general\"][\"vaccinations\"][\"secondDoses\"]}}\"}\n]"
      },
      "name": "APITemplate.io1",
      "type": "n8n-nodes-base.apiTemplateIo",
      "typeVersion": 1,
      "position": [
        820,
        480
      ],
      "credentials": {
        "apiTemplateIoApi": {
          "id": "15",
          "name": "APITemplate.io account"
        }
      }
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://discord.com/api/webhooks/904141367670865991/AaIq0nLkHRSOu0QYSXlqxPOQ3Cc5Tk8H26uvLK09zNfXRgDBfe4-NYijgiCG9Va8ja0i",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={ \n \"content\": \"<@&906366284982280213>\",\n \"embeds\": \n [\n { \n \"image\": \n { \n \"url\": \"{{$json[\"download_url\"]}}\" \n }\n }\n ] ,\n \"allowed_mentions\": \n { \n \"roles\": \n [\n \"906366284982280213\"\n ] \n },\n \"username\":\"Covid19\",\n \"avatar_url\":\"https://oecd-opsi.org/wp-content/uploads/2020/04/COVID-19-Logo.png\"\n}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1060,
        480
      ]
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "custom",
              "cronExpression": "*/5 10,11,14 * * *"
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        -60,
        600
      ]
    },
    {
      "parameters": {
        "path": "728e7a4a-d43d-4a28-9d6a-2d2de7ce3555",
        "responseMode": "lastNode",
        "responseData": "allEntries",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        -60,
        380
      ],
      "webhookId": "728e7a4a-d43d-4a28-9d6a-2d2de7ce3555"
    }
  ],
  "connections": {
    "Get data": {
      "main": [
        [
          {
            "node": "Check if already got",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if already got": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "APITemplate.io1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "APITemplate.io1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Log data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron": {
      "main": [
        [
          {
            "node": "Get data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Get data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

I added 14 to cron, but it’s not working. If I change from custom to every minute, it’s working just fine

I read docs, and it says that it should work with things from crontab.guru and crontab.guru don’t complain about my cron setting

Thanks in advance!

1 Like

Hey @Shirobachi

You don’t have to create multiple cron nodes to do this. Can be done easily with Custom Option

image

You need the below expression for this (Reference)

*/5 10-11 * * *

This will trigger the Cron node every 5 minutes between 10 - 11

2 Likes

I mean it’s pretty same like I did, my was */5 10,11,14 * * * I’ll try - instead of , between hours

I set */5 10-14 * * * but it didn’t trigger workflow


workflow is named coronavirus report and it only from 11am now is 1pm

Did you set the timezone correctly on your instance or workflow?

Yes sir :grin:

I dont understand why but workflow run at 16:05, does it have to make any sense for you guys?

Looks for me like a timezone issue.

The time from the UI is in local time, the workflow runs depending on the time that is set for the workflow and the time on the server. Maybe there is something set up wrong?

1 Like

So I don’t really understand but I changed now again and timezone was different (-5H) also workflow for error was empty, but I changed this after to error workflow. Anyway, now I changed and hope it will work properly, thanks!

1 Like