Skip to main content

Schedule Script

Mainly used for executing scheduled tasks, relying on the design of Cron expressions, can be used to start a task at a specific time or loop through tasks, such as sending requests, etc.

The entry function for scripts is async function onSchedule(context), and specific script examples can be found in the Script API Reference.

Hodor supports Cron expressions with 5 or 6 parts.
The format of the 6-part expression is: Second Minute Hour Day of month Month Day of week When creating an expression, you can use this 5-part generator or 6-part (without year) generator.
I use CrontabGuru as a reference.
Therefore, you can parse any expression consisting of numbers and *, ,, /, and - symbols.

Here are some cron examples:

  • Cron expression to execute every minute: * * * * *
  • Cron expression to execute every second: * * * * * *

Scripts can also load shared code with require('@libs/<key>'): built-in libs (@libs/base64, @libs/hex) are bundled with the app, so schedule scripts can use them out of the box (see the require guide).

The JavaScript API used by Hodor is documented in the Script API Reference.