-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
[Scheduler] Periodical triggers timing #20447
base: 6.4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,14 +286,37 @@ defined by PHP datetime functions:: | |
RecurringMessage::every('3 weeks', new Message()); | ||
RecurringMessage::every('first Monday of next month', new Message()); | ||
|
||
$from = new \DateTimeImmutable('13:47', new \DateTimeZone('Europe/Paris')); | ||
$until = '2023-06-12'; | ||
RecurringMessage::every('first Monday of next month', new Message(), $from, $until); | ||
|
||
.. tip:: | ||
|
||
You can also define periodic tasks using :ref:`the AsPeriodicTask attribute <scheduler-attributes-periodic-task>`. | ||
|
||
Be aware that the message isn't passed to the messenger when you start the | ||
scheduler. The message will only be executed after the first frequency period | ||
has passed. | ||
|
||
It's also possible to pass a from and until time for your schedule. For | ||
example, if you want to execute a command every day at 13:00:: | ||
|
||
$from = new \DateTimeImmutable('13:00', new \DateTimeZone('Europe/Paris')); | ||
RecurringMessage::every('1 day', new Message(), from: $from); | ||
|
||
Or if you want to execute a message every day until a specific date:: | ||
|
||
$until = '2023-06-12'; | ||
RecurringMessage::every('1 day', new Message(), until: $until); | ||
|
||
And you can even combine the from and until parameters for more granular | ||
control:: | ||
|
||
$from = new \DateTimeImmutable('2023-01-01 13:47', new \DateTimeZone('Europe/Paris')); | ||
$until = '2023-06-12'; | ||
RecurringMessage::every('first Monday of next month', new Message(), from: $from, until: $until); | ||
Comment on lines
+297
to
+313
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We tend to favor "documentation in code examples" over normal text. So I would suggest merging this into one code block and adding a couple inline comments, like: // execute a message every day at 13:00
$from = new \DateTimeImmutable('13:00', new \DateTimeZone('Europe/Paris'));
RecurringMessage::every('1 day', new Message(), from: $from);
// execute a message every day until a specific date
$until = '2023-06-12';
RecurringMessage::every('1 day', new Message(), until: $until);
// ... etc |
||
|
||
If you don't pass a from parameter to your schedule, the first frequency period | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can merge this paragraph with the first one you added, as it's saying the same thing? |
||
is counted from the moment the scheduler is started. So if you start your | ||
scheduler at 8:33 and the message is scheduled to perform every hour, it | ||
will be executed at 9:33, 10:33, 11:33 and so on. | ||
|
||
Custom Triggers | ||
~~~~~~~~~~~~~~~ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation are often easier to read when written in positive / direct tone. Here i think we should remove "be aware" or "only", "isnt".
(suggestion just for illustration)