Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

everyOneHundredMinutes() will it work every 100 minutes? #307

Closed
M-Shahbaz opened this issue Jun 28, 2020 · 7 comments
Closed

everyOneHundredMinutes() will it work every 100 minutes? #307

M-Shahbaz opened this issue Jun 28, 2020 · 7 comments

Comments

@M-Shahbaz
Copy link

There's a function in description:

everyFiveHundredThirtySevenMinutes()

So will it work on every five hundred thirty seven minutes?

Let's say I want to run task every 100 minutes.
Will run every 100 minutes? e.g: if first time it runs at 00:00 then next would be at 01:40
everyOneHundredMinutes()

Or could be great if possible:
everyMinutes('100')

Thanks,

@PabloKowalczyk
Copy link
Collaborator

Hello,
short answer: no, long answer: calling ->everyOneHundredMinutes() will produce expression */100 * * * * with these run dates:

| Example run dates                                        |
| #1                   | 2020-06-28 08:40:00 Europe/Warsaw |
| #2                   | 2020-06-28 09:40:00 Europe/Warsaw |
| #3                   | 2020-06-28 10:40:00 Europe/Warsaw |
| #4                   | 2020-06-28 11:40:00 Europe/Warsaw |
| #5                   | 2020-06-28 12:40:00 Europe/Warsaw |

as you can see it is definitely not every 100 minutes. It is not a bug, this is how Cron works. Probably word every is confusing, because it is really every only in some cases, like 15 minutes, 20 minutes or 30 minutes, but in other cases it is not every, for example calling everyFortyMinutes will produce there run dates:

| Example run dates                                        |
| #1                   | 2020-06-28 08:40:00 Europe/Warsaw |
| #2                   | 2020-06-28 09:00:00 Europe/Warsaw |
| #3                   | 2020-06-28 09:40:00 Europe/Warsaw |
| #4                   | 2020-06-28 10:00:00 Europe/Warsaw |
| #5                   | 2020-06-28 10:40:00 Europe/Warsaw |

You can check task's run dates, and other information, by calling Crunz's task:debug command.

@M-Shahbaz
Copy link
Author

How can we have every 100 minutes with crunz
In cron it can be possible with splitting into two tasks e.g: https://stackoverflow.com/a/247643/1865829

@PabloKowalczyk
Copy link
Collaborator

You can pass Cron expression to task, see https://github.com/lavary/crunz#the-classic-way

@rogerzanelato
Copy link

rogerzanelato commented Aug 20, 2020

@PabloKowalczyk Can you see a way of achieving it with days?

I would like a job to be executed every X days of the year. If I use a cron expression like this 0 0 */3 * * my job can be executed twice in a row when a new month start.

| Simulating with Dragonmantank\CronExpression             |
| #1                   | 2020-08-22 00:00:00 Europe/Warsaw |
| #2                   | 2020-08-25 00:00:00 Europe/Warsaw |
| #3                   | 2020-08-28 00:00:00 Europe/Warsaw |
| #4                   | 2020-08-31 00:00:00 Europe/Warsaw |
| #5                   | 2020-09-01 00:00:00 Europe/Warsaw |

This example is using three days, but in my real use case it could be any valid day number.

Thanks,

@PabloKowalczyk
Copy link
Collaborator

Hello @rogerzanelato, what about 0 0 1-30/3 * *?

@rogerzanelato
Copy link

Hello @rogerzanelato, what about 0 0 1-30/3 * *?

Hello @PabloKowalczyk, sorry for the late answer!

Unfortunately it didn't work, I tested with this expression and it skips the 31th.

| Simulating with Dragonmantank\CronExpression             |
| #1                   | 2020-08-22 00:00:00 Europe/Warsaw |
| #2                   | 2020-08-25 00:00:00 Europe/Warsaw |
| #3                   | 2020-08-28 00:00:00 Europe/Warsaw | 
| #4                   | 2020-09-01 00:00:00 Europe/Warsaw |

But it's okay, I don't think it's something possible with conventional Cron anyway, I think I'll have to handle it in my code. Thank you!

@PabloKowalczyk
Copy link
Collaborator

No problem, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants