Can background functions be scheduled?


I’m setting up a scheduled function to fetch a series of records, check a date against them, and action accordingly by updating certain fields on the record, should it be found the need to do so.

This, I feel, would be a standard requirement for a scheduled process. Even the bulleted examples on the detail page about the feature states similar processes, however, we’re only given 10 secs to handle this processing. Which in a lot of cases, wouldn’t be enough time. I don’t even think the max increase of 26 seconds would do the job for a lot of CRON’d processes.

Is it possible to utilise the background functions that can run for 15 minutes and have that scheduled instead?

Is it an option to set a scheduled function to trigger a background function (at which point, why not just open the ability to set background functions to be scheduled, if they can’t be now of course)?

And if either or both of the above are actually possible, would it be worth detailing that in the docs?


I don’t think that is the case at present; scheduled and background are separate. Good feature request to allow longer scheduled functions, though I think your workaround of having a scheduled function call a background function is probably the way to go today!

I’ll leave a note for the docs team to review this suggestion and see if they feel like they want to add it. It’s an interesting, but not majority use case…but I can see the value. Fortunately they take their work quite seriously and are also product experts so they’ll be well-equipped to make a judgment call :slight_smile:

Ah, ok - sounds good.

I can confirm that the flow of a schedule calling a background job does indeed work as expected, but yes - it would be nice to just be able to schedule the background function directly.

@fool any updates on this :slight_smile: I as asking myself the same question.

If not, I’ll do the ‘workaround’ of having a scheduled function call a background one, but wanted to see if that was still necessary :slight_smile:

Actually, based on some discussions in the past with the team, I think background functions can be indeed scheduled. A simple scheduled function, if suffixed with -background, should work. Could you try that?

Not sure thats true. I deployed a scheduled background function and it deployed under scheduled functions and then failed as it exceeded the 10s limit. I think chaining them might be the only way to do it?

Mind sharing a site name, @pariah140?

As far as as I see, for the site you mention, your scheduled function is being treated as a background function.