Reputation: 370
I am using node-cron. Please help to explain to me the different between:
var pattern_1 = '58 * * * * *';
var pattern_2 = '*/58 * * * * *';
when running this function:
new CronJob(pattern, function() {
console.log('lalalalala')
}, null, true, 'America/Los_Angeles');
Upvotes: 0
Views: 223
Reputation: 8440
The second pattern:
var pattern_1 = '58 * * * * *';
It executes at "58th seconds of every minute".
The second pattern:
var pattern_2 = '*/58 * * * * *';
Same as pattern 1 so it also executes at "58th seconds of every minute".
Upvotes: 0
Reputation: 3440
As described in cron man page:
Step values can be used in conjunction with ranges. Following a range with ''/'' specifies skips of the number's value through the range.
and:
Steps are also permitted after an asterisk, so if you want to say ''every two hours'', just use ``*/2''.
So:
var pattern_1 = '58 * * * * *';
executes "at 58th seconds of every minute". The second pattern:
var pattern_2 = '*/58 * * * * *';
executes "every 58 seconds".
Upvotes: 2
Reputation: 1156
The first patterns will run your cronjob every 58th second: 00:00:58, 00:01:58, 00:02:58...and so on.
The slash character can be used to identify periodic values. For example */15 * * * * *
means, that your job will run ever 15th second: 00:00:15, 00:00:30, 00:00:45 ...and so on.
In my opinion */58
doesn't look very useful. This will execute every 58th second of every minute, so just use the first one.
Upvotes: 0