1.1 Description A plugin that allow code execution scheduling. Groovy tasks or java plugin code can be planned to be executed according to a cron trigger. Built on the top of the [Quartz scheduling library>http://www.opensymphony.com/quartz] The quartz version used currently is the 1.4.5 1.1 Usage First, activate the plugin by editing your WEB-INF/xwiki.cfg file as follows and restart your XWiki instance: {code} xwiki.plugins=[...],com.xpn.xwiki.plugin.scheduler.SchedulerPlugin {code} 1.1 Download Bundled in the XWiki distribution (but not activated) 1.1 Example First, let's write the code we want to be scheduled. For example, a script that send an email to the XWiki admin with a list of all XWikiUsers. Let's write this code in a page named Admin.AllUsers {code} try{ String sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'"; string mailBody = "All Users : + xwiki.getNl()"; def users = xwiki.searchDocuments(sql) //Note : we can call here xwiki directly, as it's binded for us by the plugin. (context is also binded) for (String user in users) { mailBody += (user + xwiki.getNl()); } xwiki.sendMessage(xwiki.getXWikiPreference("admin_mail"),xwiki.getXWikiPreference("admin_mail"),mailBody); } catch (Exception e) { } {code} Then we need to create a XObject of the XClass XWiki.Task, to precise we want this code to be executed say every first day of each month. The code below is the way to do this from velocity. We can also use the object editor the do this. {code} \#set($task = \$doc.newObject("XWiki.Task")) \$task.set("taskName","Recent changes mail notification") \$task.set("taskClass","com.xpn.xwiki.plugin.scheduler.GroovyTask") \$task.set("cron","0 0 0 1 * ?") \$task.set("script",$xwiki.getDocument("Admin.AllUsers").content) \$task.set("status","") \$doc.save() {code} Finally, we can activate/desactivate the scheduling of this task, calling plugin's methods. On call of such methods, potential errors are returned in the context. To scheduled the task : {code} \#set ($task = \$doc.getObject("XWiki.Task")) \#if($xwiki.scheduler.scheduleTask($task)==false) \#error($context.get("error")) \#else \#info("Task successfully scheduled") \#end {code} To get the next date the code will be executed : {code} \$xwiki.scheduler.getNextFireTime($task) {code} To pause a scheduled task : {code} \#set ($task = \$doc.getObject("XWiki.Task")) \#if($xwiki.scheduler.pauseTask($task)==false) \#error(\$context.get("error")) \#else \#info("Task successfully paused") \#end {code} To resume a paused task : {code} \#set ($task = \$doc.getObject("XWiki.Task")) \#if($xwiki.scheduler.resumeTask($task)==false) \#error(\$context.get("error")) \#else \#info("Task successfully resumed") \#end {code} Finally to unscheduled a task : {code} \#set ($task = \$doc.getObject("XWiki.Task")) \#if($xwiki.scheduler.unscheduleTask($task)==false) \#error($context.get("error")) \#else \#info("Task successfully unscheduled") \#end {code} For more information you can consult the plugin's javadoc. 1.1 Result Execution of the script according to the cron expression