It's about time — Cron Jobs are here!
March 02, 2022
2 Min Read

When building backend applications you often need to run periodic and recurring tasks. For example, to send a welcome email to everyone who signed up recently. Encore provides native support for these types of use cases using Cron Jobs. Here's how easy it is:

import "encore.dev/cron"

// Send a welcome email to everyone who signed up in the last two hours.
var _ = cron.NewJob("welcome-email", cron.JobConfig{
    Title:    "Send welcome emails",
    Every:    2 * cron.Hour,
    Endpoint: SendWelcomeEmail,
})

That's it! When this is deployed, Encore will call the SendWelcomeEmail endpoint (not pictured) every 2 hours. There is no need to maintain any infrastructure; Encore itself takes care of the scheduling, monitoring and execution. Hooray!

What's more, Encore's Cloud Dashboard has a shiny new Cron Jobs dashboard to help you keep track of all your jobs. Check it out:

Cron Job dashboard

This means you can now schedule recurring tasks without worrying about:

  • How yet another configuration language works –– it's just plain Go.
  • Setting up and maintaining servers or third-party services –– it's all handled by Encore.
  • Keeping track of what jobs are running in each environment – just check the dashboard!

To get started, install the latest Encore release with encore version update and upgrade your application's dependency with go get encore.dev@latest.

Check out the docs to learn more.

Bugfixes and other improvements

  • Added support for code coverage with encore test -cover (#144)
  • Improved documentation on using external databases
  • Improved documentation on handling database migration errors
  • Improved documentation on how to use GCP (#102)
  • Fixed encore test mistakenly requiring Docker when the app has no database (#98)

Thanks to @ValeriaVG and @wisdommatt for the contributions!

What’s next

Over the coming weeks we’ll be adding several powerful features to help you build your backend. Soon we’re adding native support for Custom API Domains, Object Storage (S3), Pub/Sub, and more! – Remember, you can share your comments and ideas on our Public Roadmap.

As always, if you have questions or feedback, join us on Discord or just reply to this email. We’re excited to hear your feedback! ❤️