Simple UI to create cron expressions for Quartz Schedular
Cron is a UNIX utility used to schedule a command or script on your server to run automatically. Cron expressions represent a specific time and date. Scheduling automatic tasks can be very useful to automate repetitive tasks. Cron expressions are strings comprised of 6 or 7 characters separated by white spaces, and they can be pretty confusing.
The jQuery Cron Builder is a jQuery plugin that provides a clean user interface to create complex cron expressions. The cron expressions created by this tool is used for Quartz Job Schedular.
To use the plugin, simply initialize the DOM element using the cronBuilder method. In the first example, a function is automatically called when user does a change in the inputs. The function is passed to the cronBuilder at initialization.
Cron Expression:
$(function() { // Initialize DOM with cron builder with options $('#cron').cronBuilder({ selectorLabel: "选择时间段: ", language: "zh_CN", onChange: function(expression) { $('#example1-result').text(expression); } }); });
In the second example, the cron expression is only generated when the button is pressed. To get
the current cron expression, simply call the method getExpression()
.
Cron Expression:
$(function() { // Initialize DOM with cron builder $('#cron').cronBuilder(); // Add event handler to button $('button#generate').click(function(){ // Get current cron expression var expression=$('#cron').data('cronBuilder').getExpression(); // Dispaly cron expression $('#result').text(expression); }) });
The dev version can be downloaded here.
jQuery Cron Expression requires jQuery 1.12.0 or above.
<script type="text/javascript" src="src/jquery-cron-quartz.js" ></script> <link rel="stylesheet" type="text/css" href="src/jquery-cron-quartz.css">