Cronut
Cronut is a tool for taking a cron expression (e.g. * * * * * /bin/yes
) and outputting the times at which that cron expression will run. It supports most standard Vixie cron syntax, with some exceptions – see known issues.
Installation
- Ensure you have Ruby 2.3 or higher installed
- Run
gem install cronut
Usage
There are two ways to use Cronut:
As a command-line tool
To use Cronut as a command-line tool and get human-readable representations of a cron expression, simply run:
cronut <your_cron_expression>
For example:
cronut '*/15 0 1,15 * 1-5 /usr/bin/find'
will output:
minute 0 15 30 45
hour 0
day of month 1 15
month 1 2 3 4 5 6 7 8 9 10 11 12
day of week 1 2 3 4 5
command /usr/bin/find
As a library
After you've required Cronut in your application (via require 'cronut'
or your Gemfile), it can be used like so:
expression = Cronut::Expression.new('* * * * * /bin/yes')
=> #<Cronut::Expression:0x007f975d06c8d0>
expression.weekday.possibilities
=> [0, 1, 2, 3, 4, 5, 6]
expression.command
=> "/bin/yes"
Known Issues
The following (largely non-standard) features of some cron parsers are currently unsupported:
- Shorthand macros (e.g.
@yearly
, @monthly
, @daily
) - Compositions of lists, ranges and steps (e.g.
1-2,3,*/4
) - Alternative single values for months (e.g.
JAN
, DEC
) - Alternative single values for weekdays (e.g.
MON
, SUN
)
Development
To work on Cronut:
- Clone this repository
- Run
bundle install
- Run the tests using
rake
License
This project is licensed under the MIT License.
Contribution Guidelines
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.