Blog
/
Announcement

Introducing cron jobs and scheduled Actions

Published
November 4, 2022
Last updated
May 14, 2024
Run Javascript code to do whatever you want on a regular basis, using Gadget's new robust scheduler system.

Many Actions often need to be run on a regular basis without having to be told, such as sending out welcome emails or cleaning up defunct data. Traditionally, developers have used <inline-code>cron<inline-code> or similar utilities to kick off this repeating work, but with serverless platforms like Gadget, a different solution is needed.

This is why, starting today, Gadget apps have one-click access to a robust scheduler system that will run any Global Action on a regular basis. Gadget’s Global Actions are top-level units of work that can run JavaScript code to do whatever you need on a regular basis: send emails, write to the database, make API calls, etc.

To create a schedule, you add a new Scheduler Trigger to your Global Action, and then configure the schedule you want to run the Global Action on. For example, we could create a Global Action to send an email to us each week with a list of new customers:

Terminal

We can then trigger this Global Action weekly using the new Scheduler Trigger, which gives you the ability to set schedules based on a variety of parameters.

Scheduling a Global Action is easy, it takes just a few clicks.

Scheduled Global Actions will run the same way as a Global Action triggered by the GraphQL API.. This means the same logs will show up in your Logger, the same transaction configuration will apply, etc. Notably, Global Actions can optionally be triggered both on a schedule and via your API, so you can still run them via the API Playground or via calls in your application.

Until next *time*!

Mohammad Hashemi
Author
Reviewer
Try Gadget
See the difference a full-stack development platform can make.
Create app
No items found.

Introducing cron jobs and scheduled Actions

Run Javascript code to do whatever you want on a regular basis, using Gadget's new robust scheduler system.
Problem
Solution
Result

Many Actions often need to be run on a regular basis without having to be told, such as sending out welcome emails or cleaning up defunct data. Traditionally, developers have used <inline-code>cron<inline-code> or similar utilities to kick off this repeating work, but with serverless platforms like Gadget, a different solution is needed.

This is why, starting today, Gadget apps have one-click access to a robust scheduler system that will run any Global Action on a regular basis. Gadget’s Global Actions are top-level units of work that can run JavaScript code to do whatever you need on a regular basis: send emails, write to the database, make API calls, etc.

To create a schedule, you add a new Scheduler Trigger to your Global Action, and then configure the schedule you want to run the Global Action on. For example, we could create a Global Action to send an email to us each week with a list of new customers:

Terminal

We can then trigger this Global Action weekly using the new Scheduler Trigger, which gives you the ability to set schedules based on a variety of parameters.

Scheduling a Global Action is easy, it takes just a few clicks.

Scheduled Global Actions will run the same way as a Global Action triggered by the GraphQL API.. This means the same logs will show up in your Logger, the same transaction configuration will apply, etc. Notably, Global Actions can optionally be triggered both on a schedule and via your API, so you can still run them via the API Playground or via calls in your application.

Until next *time*!

Interested in learning more about Gadget?

Join leading agencies making the switch to Gadget and experience the difference a full-stack platform can make.