@@ -28,7 +28,7 @@ npm install --save node-cron
28
28
Import node-cron and schedule a task:
29
29
30
30
``` javascript
31
- var cron = require (' node-cron' );
31
+ const cron = require (' node-cron' );
32
32
33
33
cron .schedule (' * * * * *' , () => {
34
34
console .log (' running a task every minute' );
@@ -70,7 +70,7 @@ This is a quick reference to cron syntax and also shows the options supported by
70
70
You may use multiples values separated by comma:
71
71
72
72
``` javascript
73
- var cron = require (' node-cron' );
73
+ const cron = require (' node-cron' );
74
74
75
75
cron .schedule (' 1,2,4,5 * * * *' , () => {
76
76
console .log (' running every minute 1, 2, 4 and 5' );
@@ -82,7 +82,7 @@ cron.schedule('1,2,4,5 * * * *', () => {
82
82
You may also define a range of values:
83
83
84
84
``` javascript
85
- var cron = require (' node-cron' );
85
+ const cron = require (' node-cron' );
86
86
87
87
cron .schedule (' 1-5 * * * *' , () => {
88
88
console .log (' running every minute to 1 from 5' );
@@ -94,7 +94,7 @@ cron.schedule('1-5 * * * *', () => {
94
94
Step values can be used in conjunction with ranges, following a range with '/' and a number. e.g: ` 1-10/2 ` that is the same as ` 2,4,6,8,10 ` . Steps are also permitted after an asterisk, so if you want to say “every two minutes”, just use ` */2 ` .
95
95
96
96
``` javascript
97
- var cron = require (' node-cron' );
97
+ const cron = require (' node-cron' );
98
98
99
99
cron .schedule (' */2 * * * *' , () => {
100
100
console .log (' running a task every two minutes' );
@@ -106,7 +106,7 @@ cron.schedule('*/2 * * * *', () => {
106
106
For month and week day you also may use names or short names. e.g:
107
107
108
108
``` javascript
109
- var cron = require (' node-cron' );
109
+ const cron = require (' node-cron' );
110
110
111
111
cron .schedule (' * * * January,September Sunday' , () => {
112
112
console .log (' running on Sundays of January and September' );
@@ -116,7 +116,7 @@ cron.schedule('* * * January,September Sunday', () => {
116
116
Or with short names:
117
117
118
118
``` javascript
119
- var cron = require (' node-cron' );
119
+ const cron = require (' node-cron' );
120
120
121
121
cron .schedule (' * * * Jan,Sep Sun' , () => {
122
122
console .log (' running on Sundays of January and September' );
@@ -143,7 +143,7 @@ Arguments:
143
143
** Example** :
144
144
145
145
``` js
146
- var cron = require (' node-cron' );
146
+ const cron = require (' node-cron' );
147
147
148
148
cron .schedule (' 0 1 * * *' , () => {
149
149
console .log (' Running a job at 01:00 at America/Sao_Paulo timezone' );
@@ -160,9 +160,9 @@ Arguments:
160
160
Starts the scheduled task.
161
161
162
162
``` javascript
163
- var cron = require (' node-cron' );
163
+ const cron = require (' node-cron' );
164
164
165
- var task = cron .schedule (' * * * * *' , () => {
165
+ const task = cron .schedule (' * * * * *' , () => {
166
166
console .log (' stopped task' );
167
167
}, {
168
168
scheduled: false
@@ -176,9 +176,9 @@ task.start();
176
176
The task won't be executed unless re-started.
177
177
178
178
``` javascript
179
- var cron = require (' node-cron' );
179
+ const cron = require (' node-cron' );
180
180
181
- var task = cron .schedule (' * * * * *' , () => {
181
+ const task = cron .schedule (' * * * * *' , () => {
182
182
console .log (' will execute every minute until stopped' );
183
183
});
184
184
@@ -190,10 +190,10 @@ task.stop();
190
190
Validate that the given string is a valid cron expression.
191
191
192
192
``` javascript
193
- var cron = require (' node-cron' );
193
+ const cron = require (' node-cron' );
194
194
195
- var valid = cron .validate (' 59 * * * *' );
196
- var invalid = cron .validate (' 60 * * * *' );
195
+ const valid = cron .validate (' 59 * * * *' );
196
+ const invalid = cron .validate (' 60 * * * *' );
197
197
```
198
198
199
199
## Issues
0 commit comments