forked from kelektiv/node-cron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
23 lines (19 loc) · 673 Bytes
/
test.js
File metadata and controls
23 lines (19 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var cron = require('cron'),
sys = require('sys');
new cron.CronJob('00 * * * * *', function(){
sys.puts(new Date() + ' You will see this message when the seconds are zero');
});
new cron.CronJob('*/5 * * * * *', function(){
sys.puts(new Date() + ' You will see this message every five seconds ');
});
new cron.CronJob('10-20 * * * * *', function(){
sys.puts(new Date() + ' You will see this message from seconds ten through twenty ');
});
// How to check if a cron pattern is valid
try {
new cron.CronTime('invalid cron pattern', function() {
sys.puts('this should not be printed');
})
} catch(ex) {
sys.puts("cron pattern not valid: ", ex.message);
}