Parses Cron Expressions of the below format:
- (Minute) (hour) (day of month) (month) (day of week) (command)
*means all possible time units-a range of time units,a comma separated list of individual time units/intervals time units, the left value is the starting value and the right value is the max value
For example given the input argument:
*/15 0 1,15 * 1-5 /usr/bin/find
The output should be:
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/findThe build will build two jars:
- A plain jar that is built for use a library at build/libs/cron-java-expr-parser-1.0-SNAPSHOT.jar
- A shadow jar that is built for running as a standalone application build/libs/cron-java-expr-parser-1.0-SNAPSHOT-all.jar
To run the cron parser from command prompt,
- Build this project with gradle setup. For gradle setup, the recommendation is to download and install IntelliJ IDEA IDE
- Open the project with IntelliJ IDEA IDE and install JDK 1.8 or above.
- Setup JAVA_HOME and path for JDK 1.8. Follow this link
https://www.baeldung.com/java-home-on-windows-7-8-10-mac-os-x-linuxto set up JAVA_HOME for different OS. - Project will auto sync, if you find any difficulties in auto sync, build the project using IDE build tab
- Once all dependencies are downloaded in your local workspace, do a gradle build from gradle build script
- On latest IntelliJ IDEA IDE, gradle build script are available on the right conner 2 vertical tab.
- In gradle script under tasks>build>build, right click and run this script
- It will build your local project, and you will be able to find bundled jar under build/libs folder of you main project folder.
- Open command prompt/terminal and go to your project folder root. Then go to build/libs and run :
java -jar build/libs/cron-java-expr-parser-1.0-SNAPSHOT-all.jar "*/15 0 1,15 * 1-5 /usr/bin/find"- Following output will be displayed in your command prompt/terminal:
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