Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9caa9b4

Browse filesBrowse files
committed
minor #20447 [Scheduler] Periodical triggers timing (codedmonkey)
This PR was merged into the 6.4 branch. Discussion ---------- [Scheduler] Periodical triggers timing <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `7.x` for features of unreleased versions). --> Improves the explanation of periodical triggers in the Scheduler component. Related to #20349 Commits ------- f58f1eb [Scheduler] Periodical triggers timing
2 parents 334dc80 + f58f1eb commit 9caa9b4
Copy full SHA for 9caa9b4

File tree

Expand file treeCollapse file tree

1 file changed

+27
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+27
-4
lines changed

‎scheduler.rst

Copy file name to clipboardExpand all lines: scheduler.rst
+27-4Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,37 @@ defined by PHP datetime functions::
286286
RecurringMessage::every('3 weeks', new Message());
287287
RecurringMessage::every('first Monday of next month', new Message());
288288

289-
$from = new \DateTimeImmutable('13:47', new \DateTimeZone('Europe/Paris'));
290-
$until = '2023-06-12';
291-
RecurringMessage::every('first Monday of next month', new Message(), $from, $until);
292-
293289
.. tip::
294290

295291
You can also define periodic tasks using :ref:`the AsPeriodicTask attribute <scheduler-attributes-periodic-task>`.
296292

293+
Be aware that the message isn't passed to the messenger when you start the
294+
scheduler. The message will only be executed after the first frequency period
295+
has passed.
296+
297+
It's also possible to pass a from and until time for your schedule. For
298+
example, if you want to execute a command every day at 13:00::
299+
300+
$from = new \DateTimeImmutable('13:00', new \DateTimeZone('Europe/Paris'));
301+
RecurringMessage::every('1 day', new Message(), from: $from);
302+
303+
Or if you want to execute a message every day until a specific date::
304+
305+
$until = '2023-06-12';
306+
RecurringMessage::every('1 day', new Message(), until: $until);
307+
308+
And you can even combine the from and until parameters for more granular
309+
control::
310+
311+
$from = new \DateTimeImmutable('2023-01-01 13:47', new \DateTimeZone('Europe/Paris'));
312+
$until = '2023-06-12';
313+
RecurringMessage::every('first Monday of next month', new Message(), from: $from, until: $until);
314+
315+
If you don't pass a from parameter to your schedule, the first frequency period
316+
is counted from the moment the scheduler is started. So if you start your
317+
scheduler at 8:33 and the message is scheduled to perform every hour, it
318+
will be executed at 9:33, 10:33, 11:33 and so on.
319+
297320
Custom Triggers
298321
~~~~~~~~~~~~~~~
299322

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.