Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

Scheduled Tasks

Scheduled Tasks are currently in private beta. Please contact support@anvil.works if you are interested in trying them out

Sometimes you want to run server functions at particular times, regardless of user activity on your app. For example, you might need to run analytics on your Data Tables every night, or send out a daily email digest. For users on paid plans, Scheduled Tasks let you do just that - you can choose to run any Background Task every minute, hour, day, week, or month, on a schedule you configure.

Scheduled Tasks are for running Background Tasks on the server. To repeatedly run client code in the user’s browser, use the Timer Component.

Scheduled Tasks launch standard Background Tasks, as if you had launched them manually using anvil.server.launch_background_task(...). You can see the launched Background Tasks in the Background Tasks dialog, and find output in the App Logs

In a typical use-case, we may have defined two Background Tasks in a Server Module:

  • poll_sensor collects data from a remote sensor (probably using the Uplink).
  • send_email_digest sends a summary email, and should be run once a week.

To get started, choose Scheduled Tasks from the Gear Menu.

The Gear Menu with Scheduled Tasks highlighted.

Choose poll_sensor from the drop-down menu, confirm that we want to run it every 10 minutes (or click the parameters to change), then add the task with the green “” button.

A dialog saying 'Run poll_sensor every 10 mintes'. The 'poll_sensor', '10' and 'minutes' can be changed.

Next, Choose send_email_digest from the drop-down menu, and configure it to run every Monday at 8am. Note that all Scheduled Tasks are configured in UTC - the same time zone your Server Modules run in.

A dialog saying 'Run send_email_digest every 1 week on Monday at 08:00 UTC'. The important variables can be changed.

Click on a Scheduled Task to see when it last ran, and when it will next run.

The Scheduled Tasks dialog showing the poll_sensor task set to run every 10 minutes.