Re-schedules the task to a new date/time. The task will run again at the new date/time, even if the task returns with an error.
It is only possible to use again_at
within the callback of the parent task. If may however be used within a future or other closure, as long as this closure is nested within the tasks callback.
This function generates a change.
task.again_at(start)
Argument | Type | Description |
---|---|---|
start |
datetime (required) |
Date/time when the task should start again. |
Returns nil
when successful.
This code creates a repeating task:
start = datetime();
// Create a repeating task (daily at 23:00)
task(start, |task| {
// Run the task again in one day, relative to the current time.
// tip: use again_in() to move the task relative to the task scheduled time.
task.again_at(datetime().move('days', 1));
log('Daily task');
});
Example return value in JSON format
"<task:12 owner:admin run_at:2021-11-02T13:05:11Z status:nil>"