{"id":318,"date":"2009-12-01T12:08:55","date_gmt":"2009-12-01T06:38:55","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=318"},"modified":"2016-12-19T15:06:04","modified_gmt":"2016-12-19T09:36:04","slug":"rescheduling-a-quartz-job-programmatically","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/","title":{"rendered":"Rescheduling a Quartz job programatically"},"content":{"rendered":"<p>In our <a title=\"Grails Development\" href=\"http:\/\/www.tothenew.com\/grails-application-development\">current project on Grails<\/a> we faced a problem\u00a0 where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way-<\/p>\n<blockquote>\n<div class=\"code\">\n<pre lang=\"groovy\">class MyJob{\r\n    static triggers = {\r\n        simple name: 'mySimpleTrigger', group: 'mySimpleTriggerGroup'\r\n        }\r\n    def execute() {\r\n        println \"${new Date()} -&gt; Job run!\"\r\n    }\r\n}<\/pre>\n<\/div>\n<\/blockquote>\n<p>Name and group attributes helped us in retrieving the associated trigger instance with this job. Here is the code of the action that reschedules the above job.<\/p>\n<blockquote>\n<div class=\"code\">\n<pre lang=\"groovy\">class MyController{\r\n   def quartzScheduler                \/\/ Inject the quartzScheduler bean\r\n\r\n  def reScheduleMyJob={\r\n       def trigger = quartzScheduler.getTrigger(\"mySimpleTrigger\", \"mySimpleTriggerGroup\")\r\n\r\n       trigger.repeatInterval = 5000    \/\/ in millisecods, a long value\r\n       trigger.repeatCount=10           \/\/ Optional int value, if not set it repeats indefinately.\r\n\r\n       Date nextFireTime=quartzScheduler.rescheduleJob(trigger.name, trigger.group, trigger)\r\n\r\n       println \"Next Fire Time : ${nextFireTime}\"\r\n  }\r\n}\r\n<\/pre>\n<\/div>\n<\/blockquote>\n<p>Similarly if you are using Cron expression to schedule the job then use <code>setCronExpression<\/code> method of the trigger instance got from <code>quartzScheduler.getTrigger()<\/code> to reset the cron expression.<\/p>\n<p>It worked for us.Hope it will save your time too.<\/p>\n<p>Helpful links:-<br \/>\nhttp:\/\/old.nabble.com\/Changing-quartz-job-timeout-property-td26512630.html#a26532021<\/p>\n<p>http:\/\/grails.org\/plugin\/quartz<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our current project on Grails we faced a problem\u00a0 where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: &#8216;mySimpleTrigger&#8217;, group: &#8216;mySimpleTriggerGroup&#8217; } def [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":80,"footnotes":""},"categories":[7],"tags":[152,4840,155,148,150,149],"class_list":["post-318","post","type-post","status-publish","format-standard","hentry","category-grails","tag-gettrigger","tag-grails","tag-grails-quartz-plugin","tag-quartz-job","tag-quartz-timeout","tag-quartzscheduler"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"In our current project on Grails we faced a problem where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: &#039;mySimpleTrigger&#039;, group: &#039;mySimpleTriggerGroup&#039; } def\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Bhagwat Kumar\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Rescheduling a Quartz job programatically | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"In our current project on Grails we faced a problem where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: &#039;mySimpleTrigger&#039;, group: &#039;mySimpleTriggerGroup&#039; } def\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Rescheduling a Quartz job programatically | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"In our current project on Grails we faced a problem where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: &#039;mySimpleTrigger&#039;, group: &#039;mySimpleTriggerGroup&#039; } def\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/#article\",\"name\":\"Rescheduling a Quartz job programatically | TO THE NEW Blog\",\"headline\":\"Rescheduling a Quartz job programatically\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/bhagwat\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2009-12-01T12:08:55+05:30\",\"dateModified\":\"2016-12-19T15:06:04+05:30\",\"inLanguage\":\"en-US\",\"commentCount\":6,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/#webpage\"},\"articleSection\":\"Grails, getTrigger, Grails, grails quartz plugin, quartz job, quartz timeout, quartzScheduler\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"position\":2,\"name\":\"Grails\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/#listItem\",\"name\":\"Rescheduling a Quartz job programatically\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/#listItem\",\"position\":3,\"name\":\"Rescheduling a Quartz job programatically\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/bhagwat\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/bhagwat\\\/\",\"name\":\"Bhagwat Kumar\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d6c506f803fe26906ef802b1eaee463146e449a8b5b3d1f7e4ebc715b933d620?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Bhagwat Kumar\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/\",\"name\":\"Rescheduling a Quartz job programatically | TO THE NEW Blog\",\"description\":\"In our current project on Grails we faced a problem where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: 'mySimpleTrigger', group: 'mySimpleTriggerGroup' } def\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/rescheduling-a-quartz-job-programmatically\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/bhagwat\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/bhagwat\\\/#author\"},\"datePublished\":\"2009-12-01T12:08:55+05:30\",\"dateModified\":\"2016-12-19T15:06:04+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Rescheduling a Quartz job programatically | TO THE NEW Blog","description":"In our current project on Grails we faced a problem where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: 'mySimpleTrigger', group: 'mySimpleTriggerGroup' } def","canonical_url":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/#article","name":"Rescheduling a Quartz job programatically | TO THE NEW Blog","headline":"Rescheduling a Quartz job programatically","author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/bhagwat\/#author"},"publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"},"datePublished":"2009-12-01T12:08:55+05:30","dateModified":"2016-12-19T15:06:04+05:30","inLanguage":"en-US","commentCount":6,"mainEntityOfPage":{"@id":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/#webpage"},"isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/#webpage"},"articleSection":"Grails, getTrigger, Grails, grails quartz plugin, quartz job, quartz timeout, quartzScheduler"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.tothenew.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/grails\/#listItem","name":"Grails"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/grails\/#listItem","position":2,"name":"Grails","item":"https:\/\/www.tothenew.com\/blog\/category\/grails\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/#listItem","name":"Rescheduling a Quartz job programatically"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/#listItem","position":3,"name":"Rescheduling a Quartz job programatically","previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/grails\/#listItem","name":"Grails"}}]},{"@type":"Organization","@id":"https:\/\/www.tothenew.com\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/www.tothenew.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.tothenew.com\/blog\/author\/bhagwat\/#author","url":"https:\/\/www.tothenew.com\/blog\/author\/bhagwat\/","name":"Bhagwat Kumar","image":{"@type":"ImageObject","@id":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/d6c506f803fe26906ef802b1eaee463146e449a8b5b3d1f7e4ebc715b933d620?s=96&d=mm&r=g","width":96,"height":96,"caption":"Bhagwat Kumar"}},{"@type":"WebPage","@id":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/#webpage","url":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/","name":"Rescheduling a Quartz job programatically | TO THE NEW Blog","description":"In our current project on Grails we faced a problem where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: 'mySimpleTrigger', group: 'mySimpleTriggerGroup' } def","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/#breadcrumblist"},"author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/bhagwat\/#author"},"creator":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/bhagwat\/#author"},"datePublished":"2009-12-01T12:08:55+05:30","dateModified":"2016-12-19T15:06:04+05:30"},{"@type":"WebSite","@id":"https:\/\/www.tothenew.com\/blog\/#website","url":"https:\/\/www.tothenew.com\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Rescheduling a Quartz job programatically | TO THE NEW Blog","og:description":"In our current project on Grails we faced a problem where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: 'mySimpleTrigger', group: 'mySimpleTriggerGroup' } def","og:url":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/","og:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Rescheduling a Quartz job programatically | TO THE NEW Blog","twitter:description":"In our current project on Grails we faced a problem where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: 'mySimpleTrigger', group: 'mySimpleTriggerGroup' } def","twitter:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"318","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":"","og_description":"","og_object_type":"blog","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":"","og_article_tags":"","twitter_use_og":false,"twitter_card":"summary","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-29 13:04:18","updated":"2024-02-29 08:43:24","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\/category\/grails\/\" title=\"Grails\">Grails<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tRescheduling a Quartz job programatically\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.tothenew.com\/blog"},{"label":"Grails","link":"https:\/\/www.tothenew.com\/blog\/category\/grails\/"},{"label":"Rescheduling a Quartz job programatically","link":"https:\/\/www.tothenew.com\/blog\/rescheduling-a-quartz-job-programmatically\/"}],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=318"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/318\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}