-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
34 lines (30 loc) · 985 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require('dotenv').config({ path: process.env.PATH_ENV });
const cron = require('node-cron');
const cronMinutes = require('./cronTasks/minute');
const cronWeeks = require('./cronTasks/week');
const cronDays = require('./cronTasks/day');
const cronMonths = require('./cronTasks/month');
cron.schedule('*/10 * * * *', () => {
//every 10 minutes
cronMinutes()
.then(() => console.log('Minutes task done'))
.catch(err => console.log('Minutes task error', err));
});
cron.schedule('0 0 * * Sun', () => {
// every sunday at 00:00
cronWeeks()
.then(() => console.log('Weeks task done'))
.catch(err => console.log('Weeks task error', err));
});
cron.schedule('0 5 * * *', () => {
// every days at 5am
cronDays()
.then(() => console.log('Days task done'))
.catch(err => console.log('Days task error', err));
});
cron.schedule('0 0 1 * *', () => {
// every month the first day at 00:00
cronMonths()
.then()
.catch(err => console.log(err));
});