Schedule Later step

Run the rest of a Glue job, or another job, up to 30 days later.

The Schedule Later step runs something after a delay of up to 30 days. It can pause the rest of this job and pick it up later, or queue another job to run later while this one carries on.

For a short pause of a few seconds within the same run, use Wait instead.

Set it up

In the appdata fieldWhat it does
AmountamountA number greater than 0. Liquid works, so a script can work it out.
UnitunitSeconds, Minutes (the default), Hours or Days.
What runs latertargetRest of this job (the default) or Another job.
JobjobAnother job only: the job to queue, by ID or exact name.
Payload (optional)payloadAnother job only: sent to that job as its default variable.
Response variableresponse_variableSaves scheduled_at, plus job_id when another job is queued.

The total delay can be at most 30 days. Anything longer fails the step.

Rest of this job

The run stops at this step, as a success. When the time comes, the job picks up at the next step with the variables it had, so later steps can still use $.sale and everything else you set before the delay.

  • It has to be a top-level step. It can't sit inside an If Condition, Loop or Lock. To delay only in some cases, put a Schedule Later set to Another job inside the If Condition instead.
  • Variables are carried over, up to 1 MB. If the job's variables are bigger, the step fails with an error saying how big they are and asking you to remove large variables before the delay. Clear big responses you no longer need first, for example $.products_res = null;.
  • Save the job first. The step needs to be saved before it can schedule the rest of the job.

Another job

The other job is queued to run after the delay, and this job carries on straight away. The other job gets Payload as its default variable, up to 1 MB.

In a test (when you select Run in the job editor), Schedule Later only logs what it would do. Nothing is scheduled, and with Rest of this job the test stops at this step.

Example 1: Queue a review job for a big sale

Trigger: System Hook, Create Sale.

  1. Script: Read the sale

    var sale = JSON.parse($.default);
    $.needs_review = sale.total_price > 2000;
    $.review_payload = JSON.stringify({ sale_id: sale.id });
  2. If Condition: If the sale should be reviewed, Condition $.needs_review === true. Under THEN:

    • Schedule Later: Queue the review job, Amount 2, Unit Hours, What runs later Another job, Job Review big sales, Payload {{ review_payload }}.

Example 2: Email the customer the next day

Trigger: System Hook, Create Sale.

  1. Script: Read the sale

    var sale = JSON.parse($.default);
    $.sale_id = sale.id;
    $.customer_email = (sale.customer && sale.customer.email) || "";
  2. Schedule Later: Wait until tomorrow, Amount 1, Unit Days, What runs later Rest of this job.

  3. If Condition: If the customer has an email, Condition $.customer_email !== "".

  4. Email: Email the customer, under THEN.

Keep the variables small before the delay: here the script saves only the sale ID and email, not the whole sale.

Tips

  • Check before you act. A day later things may have changed (the sale may have been refunded, say). Look the record up again after the delay if it matters.
  • Retries don't schedule twice. A top-level Schedule Later that already worked isn't repeated when the job is retried.

← All Glue step guides


Did this page help you?