GithubHelp home page GithubHelp logo

cron-parser's Introduction

CRON Parser

This command line application parses a cron string and expands each field to show the times at which it will run.

We only consider the standard cron format with five time fields (minute, hour, day of month, month, and day of week) plus a command. The input will be on a single line. The cron string is passed as a single argument to the application.

~$ your-program "*/15 0 1,15 * 1-5 /usr/bin/find"

Limitations

  • This does not handle the special time strings such as "@yearly"
  • This does not handle if the month has less than 31 days or not

Run Instructions

IntelliJ

  • open repo in IntelliJ and use the provided IntelliJ run/debug configuration

Docker

$ docker run -it $(docker build -q .)

Shell Script

$ ./run.sh "*/15 0 1,15 * 1-5 /usr/bin/find"

The shell script checks if there is a java installation available. If not it throws and error. Else it checks if the version is >= 17. If yes, then it compiles using gradle and runs the main class from there.

Command Line

  • build the jar using
    ./gradlew clean build
  • Built jar will be in build/libs/ directory and by the name CRON-Parser-1.0-SNAPSHOT.jar
  • Run the jar using
    java -cp build/libs/CRON-Parser-1.0-SNAPSHOT.jar com.cron.Parser <CRON EXPRESSION>

Sample command and output

Command

java -cp build/libs/CRON-Parser-1.0-SNAPSHOT.jar com.cron.Parser "*/15 0 1,15 * 1-5 /usr/bin/find"

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.