Skip to main content

CRON Jobs

Create CRON Job

In order to create CRON jobs, just add a crons folder to less. Each CRON job is just another folder inside of less/crons.

Here's an example of a generate_daily_report CRON job.

mkdir -p less/crons/generate_daily_report
touch less/crons/generate_daily_report/index.js
less/crons/generate_daily_report/index.js
exports.process = async () => {
console.log('Generating report...');
};

Set CRON Schedule

In order to set the CRON schedule you will need to configure them as Environment Variables. The name of the variable should be CRON_ + the uppercase CRON folder name.

In the example of the generate_daily_report CRON the envoronment variable would be CRON_GENERATE_DAILY_REPORT:

export CRON_GENERATE_DAILY_REPORT="0 0 * * ? *"
Remember to add the env var to your less.config.
touch less.config
less.config
env_vars:
- CRON_GENERATE_DAILY_REPORT
Less Configuration Documentation

Read the Less configuration documentation to learn more about setting up environment variables.

tip

Visit the AWS Cron expressions reference for CRON expression syntax documentation.