natural-cron.js
natural-cron.js copied to clipboard
Wrong Expression
'every hour between 5pm and 8pm' gives * 17-20 * * ? * which is not the correct expression. It should be 0 0 * 17-20 * ? *
Which format do you have for cron-expressions?
To begin with, I would like to say that this is a great package, because I can't find any other nlp cron expression generator out there on npm that is as smart as this package.
However, one small downside is that the cron expressions generated somehow get flagged by crontab as a different meaning from what they should be.
After doing a quick search on google, there are a few crontab checkers to check if the cron expression is what you want it to be:
https://www.freeformatter.com/cron-expression-generator-quartz.html https://cronexpressiondescriptor.azurewebsites.net/
As I mentioned earlier, when I try to do a cron expression for 'every hour between 5pm and 8pm' gives
* 17-20 * * ? * which is not the correct expression.
The correct cron expression for that should be 0 0 * 17-20 * ? *
Hi @joshuaquek Thanks a lot, it feels great to know that you liked the package.
Regarding the issue,
The format you described (0 0 * 17-20 * ? *) contains 7 fields which means the first one is the seconds field. Right now this package doesn't have support for seconds field. So the generated expression has only 6 fields.
-
Still your reported issue is correct and for every hour, the minutes field should be
0instead of*. (We will resolve this issue in next update as early as possible) -
We will definitely add support for
secondsfield soon when we get time.
Also it looks like your required expression has some fields shuffled as compared to the default generated expression from this package. But you can easily change the generated cron expression format as per your need with optional second argument to the function call. Check out Flexible outputs section in README.