Hello, I need to create Google cloud task with long time of retry (a year for example), this will be simple post request to endpoint of my application.
I created task with
const task = {
...
scheduleTime: {
seconds: expirationAtSeconds,
}
}
const [response] = await this.taskClient.createTask(request);
Task created successfully, but I want to delay for next execution at 17202815 seconds, this means task must raise 2024-12-01, but run immediately in seconds, not how I expected.
How is possible to realize my job?
More common question - How I can use Cloud Tasks to schedule a function execution on a delay?
Hi @Alex-1999,
Welcome to Google Cloud Community!
Based on this documentation on Cloud Tasks quotas and limits, the maximum schedule time for a task is 30 days from current date and time.
As of this writing, this feature is not yet available as your current configuration is set beyond 30 days. I would suggest creating more than 1 task that would trigger after 30 days until you reach your preferred date.
I would also suggest filing this as a feature request so that our Cloud engineers could take a look at this. We don't have a specific ETA but you can keep track of its progress once the ticket has been created.
Hope this helps.
You could make a cloud Function that tracks days since execution (using a single record in Firebase):
1. Create a record in firebase that says "DaysSince" and starts at 0
2. Create a cloud function that checks that record and if it's not over 365, it adds 1
3. If it's 365 or over, trigger the task that you want via API call
3a. If its not over 365, add +1 to that record and rest
3b. If you execute the task, set the record back to 0 in firebase
4. Set a cloud task to execute this function 1 x a day at 1201.