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 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
poll_sensorcollects data from a remote sensor (probably using the Uplink).
send_email_digestsends a summary email, and should be run once a week.
To get started, choose Scheduled Tasks from the Gear Menu.
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.
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.
Click on a Scheduled Task to see when it last ran, and when it will next run.