Can I schedule events for a custom interval?

Mechanic offers several scheduler event topics (like "mechanic/scheduler/10min"), for performing work on recurring intervals. (For the full list, see the "Scheduler" section of All event topics.)

If you need an interval that isn't represented in this list, consider updating your task to add an "event" action, with a "run_at" option, explicitly scheduling the next run.

Recommendations

With this strategy, we strongly recommend...

  • ... generating your "event" action at the very end of your task.
  • ... and enabling "Perform action runs in sequence" (see Generating sequences of actions).

Doing both of these things will ensure that the next event is only queued up after the current set of actions has been completed.

Example

Subscriptions:

mechanic/user/trigger
user/task/schedule

Script:

{% action "shopify" %}
  ...
{% endaction %}

{% assign five_minutes_in_seconds = 60 | times: 5 %}

{% action "event" %}
  {
    "topic": "user/task/schedule",
    "data": null,
    "run_at": {{ "now" | date: "%s" | plus: five_minutes_in_seconds | json }},
    "task_id": {{ task.id | json }}
  }
{% endaction %}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.