cron-tax
Intuitive cronjob syntax converter
Installation
$ npm i cron-tax
Example
const cronTax = ; // create a cron job that runs every minute; // returns "* * * * *" // create a cron job that runs every minute before 9 a.m.; // returns "* 0-9 * * *" // create a cron job that runs every minute past 9 a.m.; // returns "* 9-23 * * *" // create a cron job that runs every between 9 a.m. and 5 p.m.; // returns "* 9-17 * * *" // create a cron job that runs every hour; // returns "0 * * * *" // create a cron job that runs every hour before 3 p.m.; // returns "0 0-15 * * *" // create a cron job that runs every hour after 9 p.m.; // returns "0 21-23 * * *" // create a cron job that runs every hour between 1 a.m. and 6 p.m. // returns '0 1-18 * * *' // create a cron job that runs every week at Sunday at midnight; // returns "0 0 * * 0" // weekdays are Sunday = 0 through Saturday = 6// create a cron job that runs every week at Wednesday at midnight; // returns "0 0 * * 3" // create a cron job that runs every week at Wednesday at 7 p.m.; // returns "0 19 * * 3" // create a cron job that runs every month; // returns "0 0 1 * *" // create a cron job that runs every the 15th month at midnight; // returns "0 0 15 * *" // create a cron job that runs every the 15th month at 6 p.m. // returns '0 18 15 * *' // create a cron job that runs every year at midnight on jan 1st; // returns "0 0 1 1 *" // create a cron job that runs every valentines day at 2:30 p.m.const valentines = 2019 1 12 14 30;; // returns "30 14 12 1 *"
API
Units | every(unitType) | optional params |
---|---|---|
Minute | minutes, minute, min, m | before, after, between |
Hour | hours, hour, hr, h | before, after, between |
Week | weeks, week, wk, w | weekday, at |
Month | months, month, mon, mm | day, at |
Year | years, year, yr, y | date |
Supported units
- minute
- hour
- day
- week
- month
- year
Testing cronjobs
If production is not an option, the best tool for testing cronjobs online is cronjob.guru
License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.