@@ -175,22 +175,67 @@ Then, define the trigger date/time using the same syntax as the
175175
176176 RecurringMessage::cron('* * * * *', new Message());
177177
178+ .. tip ::
179+
180+ Check out the `crontab.guru website `_ if you need help to construct/understand
181+ cron expressions.
182+
178183You can also use some special values that represent common cron expressions:
179184
180- * ``# yearly ``, ``# annually `` - Run once a year, midnight, Jan. 1 - ``0 0 1 1 * ``
181- * ``# monthly `` - Run once a month, midnight, first of month - ``0 0 1 * * ``
182- * ``# weekly `` - Run once a week, midnight on Sun - ``0 0 * * 0 ``
183- * ``# daily ``, ``# midnight `` - Run once a day, midnight - ``0 0 * * * ``
184- * ``# hourly `` - Run once an hour, first minute - ``0 * * * * ``
185+ * ``@ yearly ``, ``@ annually `` - Run once a year, midnight, Jan. 1 - ``0 0 1 1 * ``
186+ * ``@ monthly `` - Run once a month, midnight, first of month - ``0 0 1 * * ``
187+ * ``@ weekly `` - Run once a week, midnight on Sun - ``0 0 * * 0 ``
188+ * ``@ daily ``, ``@ midnight `` - Run once a day, midnight - ``0 0 * * * ``
189+ * ``@ hourly `` - Run once an hour, first minute - ``0 * * * * ``
185190
186191For example::
187192
188- RecurringMessage::cron('#daily', new Message());
193+ RecurringMessage::cron('@daily', new Message());
194+
195+ Hashed Cron Expression
196+ ~~~~~~~~~~~~~~~~~~~~~~
197+
198+ If you have many trigger scheduled at same time (for example, at midnight, ``0 0 * * * ``)
199+ this could create a very long running schedule right at this time.
200+ This may cause an issue if a task has a memory leak.
201+
202+ You can add a ``#``(for hash) symbol in expression to generate random value. The value
203+ is deterministic based on the message. This means that while the value is random, it is
204+ predictable and consistent. A message with string representation ``my task ``
205+ and a defined frequency of ``# # * * * `` will have a calculated frequency
206+ of ``56 20 * * * `` (every day at 8:56pm).
207+
208+ A hash range ``#(x-y) `` can also be used. For example, ``# #(0-7) * * * `` means daily,
209+ some time between midnight and 7am. Using the ``# `` without a range creates a range
210+ of any valid value for the field. ``# # # # # `` is short for ``#(0-59) #(0-23) #(1-28)
211+ #(1-12) #(0-6) ``.
212+
213+ You can also use some special values that represent common hashed cron expressions:
214+
215+ ====================== ========================================================================
216+ Alias Converts to
217+ ====================== ========================================================================
218+ ``#hourly `` ``# * * * * `` (at some minute every hour)
219+ ``#daily `` ``# # * * * `` (at some time every day)
220+ ``#weekly `` ``# # * * # `` (at some time every week)
221+ ``#weekly@midnight `` ``# #(0-2) * * # `` (at ``#midnight `` one day every week)
222+ ``#monthly `` ``# # # * * `` (at some time on some day, once per month)
223+ ``#monthly@midnight `` ``# #(0-2) # * * `` (at ``#midnight `` on some day, once per month)
224+ ``#annually `` ``# # # # * `` (at some time on some day, once per year)
225+ ``#annually@midnight `` ``# #(0-2) # # * `` (at ``#midnight `` on some day, once per year)
226+ ``#yearly `` ``# # # # * `` alias for ``#annually ``
227+ ``#yearly@midnight `` ``# #(0-2) # # * `` alias for ``#annually@midnight ``
228+ ``#midnight `` ``# #(0-2) * * * `` (at some time between midnight and 2:59am, every day)
229+ ====================== ========================================================================
189230
190- .. tip ::
231+ For example ::
191232
192- Check out the `crontab.guru website `_ if you need help to construct/understand
193- cron expressions.
233+ RecurringMessage::cron('#midnight', new Message());
234+
235+ .. note ::
236+
237+ The day of month range is ``1-28 ``, this is to account for February
238+ which has a minimum of 28 days.
194239
195240.. versionadded :: 6.4
196241
0 commit comments