The "sched" app has a service that, if configured to do so, will fire some events at regular intervals. You can use listeners to catch these events in order to perform tasks on schedule. The services uses the node-cron module.
This table lists events fired by the "sched" service.
Event Name | Schedule |
---|---|
"every_minute" | Fires every minute on the minute. |
"every_half_hour" | Fires every half-hour on the hour and 30-minute mark. |
"every_hour" | Fires every hour on the hour. |
"every_day" | Fires every day at midnight. |
"every_week" | Fires every Sunday at midnight. |
"every_half_month" | Fires every month on the 1st and 15th at midnight. |
"every_month" | Fires every month on the 1st at midnight. |
This is the default configuration for the "sched" app:
module.exports = {
runCron: false
};
The events listed above are not fired unless runCron
is set to true.
You can copy the configuration to your project for editing at config/sched.js
using the following command:
node . publish --config sched
You can listen for these scheduled events the same way you listen
for any other events, by defining listeners in the events.js
file
in an app directory.
// apps/my_custom_app/events.js
module.exports = {
every_minute: [
() => { console.log("This will print every minute."); }
],
every_month: [
() => { console.log("This will print every month."); }
]
}