Scheduler API
Headless Client Plugin Guide / Scheduler API
Overview
The Scheduler API provides functionality for scheduling tasks to be executed at specified times or intervals. This is useful for automating recurring tasks like backups, data syncs, or periodic cleanups. The tasks are still subject to Servoy’s single-threaded nature, so any running method will block other tasks from executing.
You can find more detailed information about Scheduler API here.
Features
Time-Based Execution: Methods can be scheduled to run at a specific time or at regular intervals.
CRON Expressions: The Scheduler API supports CRON expressions for highly flexible task scheduling.
Job Management: Jobs can be created, listed, and removed as needed.
Add a job
Here is an example for adding job / scheduling a simple task:
Add a job with repeating interval
Here is an example for adding job with repeating interval using plugins.scheduler.addCronJob(jobname, startDate, method, repeatInterval, repeatCount) method:
The example will alternate between Ping and Pong every 1 second, for 10 times.
Add a CRON job
In Servoy, a CRON job is a scheduled task that runs at specified times or intervals using the Scheduler API. CRON jobs in Servoy allow you to automate server-side tasks based on time expressions called CRON expressions. These jobs are useful for recurring tasks such as data synchronization, backups, report generation, and other maintenance tasks that need to run periodically without user intervention.
Here are a few CRON timings generator websites:
Here is an example for adding a CRON job that runs every hour, using plugins.scheduler.addCronJob:
Here is an example for adding a CRON job that runs every Monday, using plugins.scheduler.addCronJob method:
List/Remove jobs
Here is an example for listing and removing scheduled jobs using plugins.scheduler.getCurrentJobNames and plugins.scheduler.removeJob method:
Last updated