Task files are JSON files (with name format YYYY-MM-DD-id-N.json
) placed in
application/tasks
. These files will be created and deleted automatically.
On the application server start all files will be loaded into a special thread
to be executed.
How to schedule a task:
application.scheduler.add({
name: 'name',
every: 'Jul 22th 100s',
args: { i: 2 },
run: 'lib.task1.f1',
});
Task file fields:
id: string
- task unique identifier (example:"2021-07-22-id-0"
);name: string
- not unique task name;every: string
- (example:Jul 22th 100s
), see format below;args: object
- task arguments (example:{"i":2}
);run: string
- function name to run (example:lib.task1.f1
);
Task file example:
{
"id": "2021-07-22-id-0",
"name": "name",
"every": "Jul 22th 100s",
"args": { "i": 2 },
"run": "lib.task1.f1"
}
Apr 1st
- once at00:00
1st of April15th 100s
- every 100 seconds each 15thSun 17:
- every Sunday at17:00
20th 17:15
- every 20th of any month at17:15
Apr Sun :30
- at HH:30 every hour on Sunday of April2nd :30
- every 2nd of any month at HH:30 every hourSun 3rd 00:
- every Sunday if this day will be 3rd of month at00:00
30m 17s
- interval 30 minutes and 17 secondsSun 5h 30m
- every Sunday with interval 5 hours 30 minutes2021-07-20
- certain date2021-07-20 17:30
- certain date and time