> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-framework/module-development/capabilities/schedulers.md).

# Schedulers

{% hint style="warning" %}
Schedulers require **Java**. There is no BoxLang-only mechanism for registering module-level schedulers.
{% endhint %}

Schedulers provide cron-like scheduled task execution. They integrate with BoxLang's `SchedulerService`.

## Creating a Scheduler

Implement the `IScheduler` interface and register via ServiceLoader:

**File:** `src/main/java/ortus/boxlang/modules/mymodule/schedulers/CleanupScheduler.java`

```java
import ortus.boxlang.runtime.async.tasks.IScheduler;
import ortus.boxlang.runtime.async.tasks.BaseScheduler;
import ortus.boxlang.runtime.async.tasks.ScheduledTask;

public class CleanupScheduler extends BaseScheduler {

    @Override
    public void configure() {
        // Schedule a task every hour
        ScheduledTask task = task( "cleanup-temp-files" )
            .call( () -> {
                System.out.println( "Cleaning up temp files..." );
                // Cleanup logic
            })
            .everyHour()
            .onFailure( ( task, exception ) -> {
                getLogger().error( "Cleanup failed", exception );
            });

        register( task );
    }
}
```

**ServiceLoader Config:** `src/main/resources/META-INF/services/ortus.boxlang.runtime.async.tasks.IScheduler`

```
ortus.boxlang.modules.mymodule.schedulers.CleanupScheduler
```

## Scheduler Naming

Schedulers are automatically registered with the name `{schedulerName}@{moduleName}`. For example, a `CleanupScheduler` in a module named `myModule` is registered as `CleanupScheduler@myModule`.

## Available Patterns

The `BaseScheduler` provides a fluent API for common scheduling patterns:

```java
// Every 5 minutes
task( "my-task" )
    .call( () -> doWork() )
    .everyMinute( 5 );

// Daily at 2 AM
task( "daily-task" )
    .call( () -> doWork() )
    .daily( 2, 0 );

// Cron expression
task( "cron-task" )
    .call( () -> doWork() )
    .cron( "0 0 * * *" );
```

## Next Steps

* [Services](/boxlang-framework/module-development/capabilities/services.md) — Global runtime services (Java only)
* [Cache Providers](/boxlang-framework/module-development/capabilities/cache-providers.md) — Custom caching backends (Java only)
* [JDBC Drivers](/boxlang-framework/module-development/capabilities/jdbc-drivers.md) — Database driver registration (Java only)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-framework/module-development/capabilities/schedulers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
