Get Started with Scheduled Code
Scheduled code allows you to execute one of your custom endpoints on a specific date in the future. If you haven’t already created a custom endpoint, read the Custom Endpoints guide to get up to speed.
Scheduled Code is commonly used to:
- Aggregate, archive, and cleanup data.
- Pull data from a third-party API into Kinvey.
- Send out a batch of e-mails or push notifications.
Your first schedule
To add a schedule, browse to Scheduled Code under Business Logic in the left sidebar, click Add Scheduled Endpoint and select which custom endpoint you'd like to run on a schedule. If you don't have any custom endpoints, you'll need to create one first.
You can choose whether to run the custom endpoint once or on various intervals using the Interval drop-down list.
For one-time jobs, the Start date & time specifies the execution time. For repeated jobs, this field specifies the date and time of the first execution.
After defining the execution schedule, don't forget to click the Save button.
Repeat
To execute the custom endpoint repeatedly, select a schedule other than once from the Interval drop-down list. You can choose to repeat weekly, daily, hourly, every 30 minutes, or every 5 minutes.
The example below demonstrates how to execute a custom endpoint every day at 3:00 AM (UTC). In this case, the first execution will happen the next day, because the local clock is already past 3 o'clock.
One-time
To execute the Custom Endpoint only once, click the Interval drop-down list and select the once option.
The example below demonstrates how to execute a custom endpoint to send out a bunch of Happy New Year emails. Assume the emails need to be sent when Boston (UTC-05:00) celebrates, but you are viewing the Console while on the West cost (UTC-08:00). Therefore, you need to adjust the time and instead of entering 12:01 AM on Jan 1 you need to enter three hours earlier, 9:01 PM on Dec 31.
Update a schedule
You can update a schedule any time and the update will come in effect immediately. For recurring jobs, the next execution and all the executions that follow after that will be rescheduled.
To update a schedule, find its entry on the Business Logic > Scheduled Code page and click the pencil button. Make you changes and click Save.
Cancel a schedule
If you want to stop executing a recurring job or to cancel a one-time job that hasn't passed yet, you need to delete the schedule.
To delete a schedule, find its entry on the Business Logic > Scheduled Code page, click the trashcan button, and confirm the deletion.