Background Tasks (Cron Jobs)
What are Background Tasks?
Tasks are only available on the Launch and Scale plans.
In programming Tasks are called "Background Tasks" or "Cron (Command run on...) job"
Think of a Task like an API endpoint that can be run automatically at a certain time, or is repeated at a certain time. You can add a schedule of when to start, when it should end, and the frequency.
Like an API, a Task has a Function Stack except it does not take any inputs or provide a response.
When to use Background Tasks
Background Task Resources
Background tasks are given their own dedicated resources to ensure that they can continue to run uninterrupted over a period of time, regardless of whatever else is happening in your instance. Because background tasks have their own resources, you may find that execution time differs from a normal Run & Debug of the same functions. This is normal and expected. If you require faster execution than your background tasks are currently reaching, please reach out to support and we can make any recommendations up to and including upgrading your Xano plan.
When you Run & Debug in a background task, this utilizes normal resources, and not the dedicated background task compute.
Task History
Background tasks offer task history, which allows you to view previously executed and currently running tasks.
Access the task history by clicking the three dots in the top-right corner and choosing Task History.
Your background task can have a few different statuses: Processing, Complete, Error, and Timeout.
You can click on an individual task to see the current status, execution time, and duration. For tasks currently processing, you can see the current active statement.
Background Task Timeouts, and what they mean
You might find that a background task has a status of "Timeout!" listed in the task history. Currently, while a background task is not limited in the amount of time it has to execute, if the execution surpasses 4 hours, the task will report as timed out. This does not mean that the task has stopped executing, but it does indicate an unusually extended period of time to run.
A good way to determine if your task is still running past the timeout point is to consider what the function stack is doing in this task, and manually check to see if it is still progressing. This could be as simple as if the background task is updating database data to check the table being updated.
If your task is still executing, but has reported timed out, the status will update again to Success once execution has completed.
If you have any questions about a timed out background task, please reach out to Support.
Last updated