Schedule 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.
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
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 Unix — minute hour day-of-month month day-of-week
6-field Quartz — second 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:
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
📋 Tasks File Reference (tasks.json)
tasks.json)Every create, update, and delete operation writes the full task registry to disk at ${boxLangHome}/config/tasks.json (configurable via scheduler.tasksFile). The file is a JSON array — one object per task — and is re-read on every runtime startup to restore all persisted tasks.
Below is a fully annotated example of a single task entry, followed by a field-by-field reference.
Annotated Example
Never edit username, password, proxyUser, or proxyPassword values by hand. These are encrypted with AES using the runtime's .seed file. Always use bx:schedule action="update" to change credentials.
Field Reference
🗂️ Identity
task
string
(required)
Unique task name within the scheduler. Used as the primary identifier for all actions.
scheduler
string
"default"
Name of the BaseScheduler instance that owns this task. Automatically created if it does not exist.
group
string
null
Logical grouping label. Lets you pauseall/resumeall a subset of tasks at once.
paused
boolean
false
Runtime paused state. Set to true by action="pause" and back to false by action="resume". Restored on startup.
⏰ Scheduling
interval
string
null
Repeat interval in seconds, or a named value: once, daily, weekly, monthly. Mutually exclusive with cronTime.
cronTime
string
null
Cron expression. Accepts 5-field Unix (minute hour dom month dow) or 6-field Quartz (second minute hour dom month dow). Mutually exclusive with interval.
startDate
string
null
ISO-8601 date (YYYY-MM-DD). Task will not fire before this date.
startTime
string
null
Time-of-day (HH:mm) paired with startDate to form the activation instant.
endDate
string
null
ISO-8601 date after which no more firings occur.
endTime
string
null
Time-of-day paired with endDate to form the deactivation instant.
repeat
integer
0
Maximum number of executions. 0 (or null) means unlimited.
exclude
string
null
Comma-separated dates or ranges to skip. Example: "2026-07-04,2026-12-24 to 2026-12-26".
isDaily
boolean
false
Derived convenience flag; true when the task fires once per day regardless of cron/interval. Managed by the runtime.
🌐 HTTP Request
url
string
(required)
Full URL that the scheduler fires via HTTP GET on each execution.
port
integer
null
Override the URL's default port (e.g., 8080 for HTTP, 443 for HTTPS).
resolveURL
boolean
false
When true, relative URLs in the HTTP response are rewritten to absolute URLs before any output is captured.
🔐 Credentials
username
string
null
HTTP Basic Auth username. Stored as ENC:<base64> — AES-encrypted with the runtime seed.
password
string
null
HTTP Basic Auth password. Same encryption scheme as username.
proxyServer
string
null
Proxy server hostname or IP.
proxyPort
integer
null
Proxy server port.
proxyUser
string
null
Proxy authentication username. Encrypted at rest.
proxyPassword
string
null
Proxy authentication password. Encrypted at rest.
📄 Output Publishing
publish
boolean
false
When true, the HTTP response body is written to disk after each run.
path
string
null
Directory path to write the published file to. Required when publish is true.
file
string
null
Filename for the published output. Required when publish is true.
overwrite
boolean
true
Whether to overwrite an existing file at path/file on each run. Set to false to append/skip.
🔁 Error Handling & Callbacks
retryCount
integer
0
Number of times to retry a failed HTTP request before triggering onException behaviour.
onException
string
"refire"
What to do when all retries are exhausted. Values: refire (try again next interval), pause (auto-pause the task), invokeHandler (call eventhandler).
eventhandler
string
null
Absolute path to a BoxLang file (.bx) invoked when onException is invokeHandler. Receives the task context as an argument.
oncomplete
string
null
Absolute path to a BoxLang file invoked after every successful execution, regardless of retry behaviour.
🌍 Cluster
cluster
boolean
false
When true, the SchedulerService uses the configured cacheName to ensure the task fires on only one node at a time in a cluster.
Minimal Task Entry
The smallest valid tasks.json entry that will be re-loaded on startup:
All other fields default to null / false / 0 and are safe to omit.
Related
Last updated
Was this helpful?
