githubEdit

calendar-clockSchedule Component

HTTP-driven scheduled tasks via the bx:schedule component

The bx:schedule component lets you create, manage, and persist HTTP-driven scheduled tasks directly from BoxLang templates and scripts. Each task fires an HTTP GET request to a URL of your choice on a defined schedule, making it the simplest way to trigger periodic work without writing a full Scheduler class.

circle-info

If you need to run arbitrary BoxLang code (not just HTTP calls) on a schedule, use the Scheduler DSL instead. Both approaches share the same SchedulerService under the hood.

Choosing an Approach

bx:schedule
Scheduler DSL

Runs

HTTP GET requests

Any BoxLang code

Defined in

Templates / scripts

Scheduler class files

Persisted automatically

Yes (tasks.json)

No (must reload on startup via config)

Cron support

Yes

Yes (.cron())

Best for

Simple webhooks, endpoint pings, web callbacks

In-process computation, complex task logic


Creating a Task

Every create call requires a task name, a url, and either an interval or a cronTime.

Interval-based scheduling

// Run every 5 minutes (300 seconds)
bx:schedule action="create"
    task="pingHealthCheck"
    url="https://myapp.com/health"
    interval="300";

Named intervals are also accepted:

Valid named intervals: once, daily, weekly, monthly.

Cron-based scheduling

Cron expression formats

BoxLang supports two cron formats:

5-field Unixminute hour day-of-month month day-of-week

6-field Quartzsecond minute hour day-of-month month day-of-week

Special characters: * (all), ? (any), - (range), , (list), / (step), L (last).


Updating and Deleting Tasks

Use update (or its alias modify) when you want create-or-replace semantics. Use create when you want a hard error if the task already exists.


Pausing and Resuming Tasks

You can scope pauseall / resumeall to a task group:


Listing Tasks


Running a Task Immediately

This fires the task's HTTP request right now, independent of its normal schedule.


Authentication and Proxies

Credentials are stored encrypted in tasks.json using the runtime's .seed file.


Publishing Output to Disk

Set publish="true" to capture the HTTP response body and write it to a file after each run.


Date and Time Constraints

Restrict when a task is active using startDate, startTime, endDate, and endTime. You can also exclude specific dates:

Date ranges are also valid in exclude: "2026-12-24 to 2026-12-26".


Limiting Executions

Use repeat to cap the total number of runs:


Exception Handling

Configure what happens when all retries are exhausted with onException:

Value
Behaviour

refire (default)

Re-attempt on the next scheduled interval

pause

Automatically pause the task

invokeHandler

Call the BoxLang file at eventHandler


Persistence

Tasks are automatically saved to ${boxLangHome}/config/tasks.json after every create, update, or delete operation. When the BoxLang runtime starts, it reads this file and re-registers all tasks in the scheduler.

You can customise the storage location in boxlang.json:

This is useful in clustered environments where multiple instances share a mounted volume.


Tag Syntax Reference


Last updated

Was this helpful?