A cron expression is a string used to define a schedule for executing tasks, especially in UNIX-like systems. They are commonly used in cron jobs to specify the timing of script execution. Cron expressions are also used in various Java frameworks (like Spring) for scheduling tasks.
Cron expressions typically consist of five or six fields, separated by spaces, which represent different time intervals: Here is the breakdown of each field:
- Seconds: Specifies the second of the minute (0-59). Optional in most systems, but supported in some.
- Minutes: Specifies the minute of the hour (0-59).
- Hours: Specifies the hour of the day (0-23).
- Day of the Month: Specifies the day of the month (1-31).
- Month: Specifies the month (1-12).
- Day of the Week: Specifies the day of the week (0-7, where both 0 and 7 represent Sunday).
- * : Matches any value (e.g., every minute, every hour).
- , : Separates items in a list (e.g., "1,15" means at minutes 1 and 15).
- - : Specifies a range (e.g., "1-5" means Monday to Friday).
- / : Specifies an increment (e.g., "*/5" means every 5th minute).
-
Clone the project in a local repo
-
Open terminal in folder : /path/to/repo/CronJobParser
-
Provide the cron expression and the command to be executed in the following format :
./run_cron_parser.sh "Cron_Expression command" Example : cd /path/to/folder/CronJobParser ./run_cron_parser.sh (Prompt)Enter the cron expression string: */15 0 1,15 * 1-5 /usr/bin/find