diff --git a/packages/core/src/ActiveWorkflows.ts b/packages/core/src/ActiveWorkflows.ts
index 9cd4f0079a..8ae57291d4 100644
--- a/packages/core/src/ActiveWorkflows.ts
+++ b/packages/core/src/ActiveWorkflows.ts
@@ -134,6 +134,14 @@ export class ActiveWorkflows {
cronTimes.push(`${Math.floor(Math.random() * 60).toString()} * * * * *`);
continue;
}
+ if (item.mode === 'everyX') {
+ if (item.unit === 'minutes') {
+ cronTimes.push(`${Math.floor(Math.random() * 60).toString()} */${item.value} * * * *`);
+ } else if (item.unit === 'hours') {
+ cronTimes.push(`${Math.floor(Math.random() * 60).toString()} 0 */${item.value} * * *`);
+ }
+ continue;
+ }
for (parameterName of parameterOrder) {
if (item[parameterName] !== undefined) {
diff --git a/packages/nodes-base/nodes/Cron.node.ts b/packages/nodes-base/nodes/Cron.node.ts
index 90ad6214ce..7f91b401ee 100644
--- a/packages/nodes-base/nodes/Cron.node.ts
+++ b/packages/nodes-base/nodes/Cron.node.ts
@@ -55,27 +55,31 @@ export class Cron implements INodeType {
options: [
{
name: 'Every Minute',
- value: 'everyMinute'
+ value: 'everyMinute',
},
{
name: 'Every Hour',
- value: 'everyHour'
+ value: 'everyHour',
},
{
name: 'Every Day',
- value: 'everyDay'
+ value: 'everyDay',
},
{
name: 'Every Week',
- value: 'everyWeek'
+ value: 'everyWeek',
},
{
name: 'Every Month',
- value: 'everyMonth'
+ value: 'everyMonth',
+ },
+ {
+ name: 'Every X',
+ value: 'everyX',
},
{
name: 'Custom',
- value: 'custom'
+ value: 'custom',
},
],
default: 'everyDay',
@@ -94,7 +98,8 @@ export class Cron implements INodeType {
mode: [
'custom',
'everyHour',
- 'everyMinute'
+ 'everyMinute',
+ 'everyX',
],
},
},
@@ -113,7 +118,8 @@ export class Cron implements INodeType {
hide: {
mode: [
'custom',
- 'everyMinute'
+ 'everyMinute',
+ 'everyX',
],
},
},
@@ -196,6 +202,48 @@ export class Cron implements INodeType {
default: '* * * * * *',
description: 'Use custom cron expression. Values and ranges as follows:
- Seconds: 0-59
- Minutes: 0 - 59
- Hours: 0 - 23
- Day of Month: 1 - 31
- Months: 0 - 11 (Jan - Dec)
- Day of Week: 0 - 6 (Sun - Sat)
',
},
+ {
+ displayName: 'Value',
+ name: 'value',
+ type: 'number',
+ typeOptions: {
+ minValue: 0,
+ maxValue: 1000,
+ },
+ displayOptions: {
+ show: {
+ mode: [
+ 'everyX',
+ ],
+ },
+ },
+ default: 2,
+ description: 'All how many X minutes/hours it should trigger.',
+ },
+ {
+ displayName: 'Unit',
+ name: 'unit',
+ type: 'options',
+ displayOptions: {
+ show: {
+ mode: [
+ 'everyX',
+ ],
+ },
+ },
+ options: [
+ {
+ name: 'Minutes',
+ value: 'minutes'
+ },
+ {
+ name: 'Hours',
+ value: 'hours'
+ },
+ ],
+ default: 'hours',
+ description: 'If it should trigger all X minutes or hours.',
+ },
]
},
],
@@ -236,6 +284,14 @@ export class Cron implements INodeType {
cronTimes.push(`${Math.floor(Math.random() * 60).toString()} * * * * *`);
continue;
}
+ if (item.mode === 'everyX') {
+ if (item.unit === 'minutes') {
+ cronTimes.push(`${Math.floor(Math.random() * 60).toString()} */${item.value} * * * *`);
+ } else if (item.unit === 'hours') {
+ cronTimes.push(`${Math.floor(Math.random() * 60).toString()} 0 */${item.value} * * *`);
+ }
+ continue;
+ }
for (parameterName of parameterOrder) {
if (item[parameterName] !== undefined) {
diff --git a/packages/workflow/src/NodeHelpers.ts b/packages/workflow/src/NodeHelpers.ts
index d398be8394..a1b631a19f 100644
--- a/packages/workflow/src/NodeHelpers.ts
+++ b/packages/workflow/src/NodeHelpers.ts
@@ -77,6 +77,10 @@ export function getSpecialNodeParameters(nodeType: INodeType) {
name: 'Every Month',
value: 'everyMonth',
},
+ {
+ name: 'Every X',
+ value: 'everyX',
+ },
{
name: 'Custom',
value: 'custom',
@@ -99,6 +103,7 @@ export function getSpecialNodeParameters(nodeType: INodeType) {
'custom',
'everyHour',
'everyMinute',
+ 'everyX',
],
},
},
@@ -118,6 +123,7 @@ export function getSpecialNodeParameters(nodeType: INodeType) {
mode: [
'custom',
'everyMinute',
+ 'everyX',
],
},
},
@@ -200,6 +206,48 @@ export function getSpecialNodeParameters(nodeType: INodeType) {
default: '* * * * * *',
description: 'Use custom cron expression. Values and ranges as follows:- Seconds: 0-59
- Minutes: 0 - 59
- Hours: 0 - 23
- Day of Month: 1 - 31
- Months: 0 - 11 (Jan - Dec)
- Day of Week: 0 - 6 (Sun - Sat)
',
},
+ {
+ displayName: 'Value',
+ name: 'value',
+ type: 'number',
+ typeOptions: {
+ minValue: 0,
+ maxValue: 1000,
+ },
+ displayOptions: {
+ show: {
+ mode: [
+ 'everyX',
+ ],
+ },
+ },
+ default: 2,
+ description: 'All how many X minutes/hours it should trigger.',
+ },
+ {
+ displayName: 'Unit',
+ name: 'unit',
+ type: 'options',
+ displayOptions: {
+ show: {
+ mode: [
+ 'everyX',
+ ],
+ },
+ },
+ options: [
+ {
+ name: 'Minutes',
+ value: 'minutes'
+ },
+ {
+ name: 'Hours',
+ value: 'hours'
+ },
+ ],
+ default: 'hours',
+ description: 'If it should trigger all X minutes or hours.',
+ },
],
},
],