Invalid cron expression

Hey, does anyone know the fix for this?

I’ve doubled checked the expression with Crontab guru and don’t see anything wrong w/ it.

Hi @Leonard_Chin

Looks good to me!

0 6 * * MON

can you share some info about your n8n version, setup…etc

1 Like

version 3.8 i believe

I just self-hosted it on DigitalOcean and bumped into this as I was turning on the active toggle

Is the Date & Time node working on your instance?

1 Like

yes, it’s working just fine

@mohamed3nan

My Date & Time is having issues now…

Where you host the n8n ?

or it’s cloud version

Seems like the machine that running the n8n have the date time issue.

please share your n8n version info, setup, environment variables…etc

This is just a hunch, but did you notice the tip below the field? There is an extra positional field/parameter in there for second. I think this might be slightly different than the normal Crontab expression syntax.

|        | Sec | Min  | Hr  | Day of Mon  | Month |  Day of Wk |
|--------|-----|------|-----|-------------|-------|------------|
| Yours  |  0  |  6   |  *  |     *       |  MON  |    ???     |
|--------|-----|------|-----|-------------|-------|------------|
| Fixed? |  0  |  0   |  6  |     *       |   *   |    MON     |
1 Like

@darrell_tw @hubschrauber @mohamed3nan

Thanks for your help! I have managed to solve it by changing “Mon” to “1”, “Tues” to “2”, etc. It seems like DigitalOcean has another set of rule.

But anyways, I have switched back to cloud for the AI prompting function since I’m not a code-savvy guy.

2 Likes

I know you already got this resolved but it was still bugging me that changing to a numeric weekday fixed it.

If I’m following, your expression is now 0 6 * * 1, intending to run at 6am every Monday. I might have read that as 6 minutes after every hour in January, but there seems to be some logic that counts the parameters (5 or 6) and assumes the first one (seconds) is omitted instead of the last one (day of week). Still not sure why your original expression 0 6 * * MON didn’t work.

n8n passes the cron expression, as-is, directly to the cron sendAt() function, and
The documentation for the npm cron module, re: 5 vs 6 parameters, ambiguously states → “but remember to account for the seconds field”.

The 5-parameter examples in the n8n docs seem to work, so I’m adding some things I tried for anyone who finds this thread in the future.

|                                      | Sec | Min  | Hr  | Day of Mon  | Month |  Day of Wk |
|--------------------------------------|-----|------|-----|-------------|-------|------------|
| 6am on Mondays                       |  -  |  0   |  6  |     *       |   *   |     1      | 
|--------------------------------------|-----|------|-----|-------------|-------|------------|
| Fully specified 6 am on Mondays      |  0  |  0   |  6  |     *       |   *   |    MON     |
|--------------------------------------|-----|------|-----|-------------|-------|------------|
| 6 am Monday alt w/ numeric weekday   |  0  |  0   |  6  |     *       |   *   |     1      |
|--------------------------------------|-----|------|-----|-------------|-------|------------|
| runs every 5 mins from start time    |  -  | */5  |  *  |     *       |   *   |     *      |