Saltearse al contenido
sern

scheduledTask

scheduledTask(ism): ScheduledTask

Creates a scheduled task that can be executed at specified intervals using cron patterns

Parameters

ism: ScheduledTask

The scheduled task configuration object

Returns

ScheduledTask

The configured scheduled task

Example

1
// Create a task that runs every minute
2
export default scheduledTask({
3
trigger: "* * * * *",
4
execute: (context) => {
5
console.log("Task executed!");
6
}
7
});

Remarks

  • Tasks must be placed in the ‘tasks’ directory specified in your config
  • The file name serves as a unique identifier for the task
  • Tasks can be cancelled using deps[‘@sern/scheduler’].kill(uuid)

See

https://crontab.guru/ for testing and creating cron patterns

Source

src/core/modules.ts:132