{"id":5351,"date":"2020-11-19T14:54:56","date_gmt":"2020-11-19T19:54:56","guid":{"rendered":"https:\/\/batchpatch.com\/?p=5351"},"modified":"2020-11-19T14:56:38","modified_gmt":"2020-11-19T19:56:38","slug":"using-the-task-scheduler-to-execute-a-custom-job-queue","status":"publish","type":"post","link":"https:\/\/batchpatch.com\/using-the-task-scheduler-to-execute-a-custom-job-queue","title":{"rendered":"Using the Task Scheduler to Execute a Custom Job Queue"},"content":{"rendered":"<h2 class=\"brownishOrange\">Create a custom job queue<\/h2>\n<ol>\n<li>Let&#8217;s start by creating our custom job queue.  Select &#8216;<em>Actions > Job Queue > Create\/modify job queue<\/em>&#8216;<\/li>\n<p><\/p>\n<li>In the Job Queue window, create your desired queue.  In this case I have created a queue to execute an update + reboot cycle, indefinitely, until there are no more updates available to download\/install.  My queue is as follows:<br \/>\n<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"text\" style=\"font-family:monospace;\">Label:START\nDownload and install updates + reboot always\nWait 15 minutes\nWait for host to be detected online\nCheck for available updates (with filters applied)\nIf most recent 'Check for available updates (with filters applied) found any updates, goto label:START<\/pre><\/td><\/tr><\/table><\/div>\n\n<p><a href=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_21_22-Job-Queue.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/uploads\/2020\/11\/2020-11-19-14_21_22-Job-Queue.png\" alt=\"\" width=\"1009\" height=\"601\" class=\"aligncenter size-full wp-image-5352\" srcset=\"https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_21_22-Job-Queue.png 1009w, https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_21_22-Job-Queue-300x179.png 300w, https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_21_22-Job-Queue-768x457.png 768w\" sizes=\"auto, (max-width: 1009px) 100vw, 1009px\" \/><\/a><\/p>\n<\/li>\n<p><\/p>\n<li>Give the queue a title (mine is &#8216;<em>Update + Reboot Cycle<\/em>&#8216;), and then click the double-right arrow to save it.<\/li>\n<p><\/p>\n<li>Now that our custom queue has been created and saved, we can setup our scheduled task.  Highlight the rows in the grid that you want the scheduled task to apply to.  Next, click on &#8216;<em>Actions > Task scheduler > Create\/modify scheduled task<\/em>&#8216;<\/li>\n<p><\/p>\n<h2 class=\"brownishOrange\">Create a scheduled task to execute your saved job queue<\/h2>\n<li>In the Task Scheduler window, from the Task drop-down menu find the job queue that you created, and then select it.  Next, set the run date and time.  You&#8217;ll do this by modifying the &#8216;Reference&#8217; datetime picker.  Optionally select a recurrence option.  Then click OK.<br \/>\n<br \/>\n<a href=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_32_30-new-1-BatchPatch.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_32_30-new-1-BatchPatch.png\" alt=\"\" width=\"649\" height=\"410\" class=\"aligncenter size-full wp-image-5357\" srcset=\"https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_32_30-new-1-BatchPatch.png 649w, https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_32_30-new-1-BatchPatch-300x190.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/a>\n<\/li>\n<p><\/p>\n<li>The only thing left to do now is make sure that the task scheduler is enabled.  In the upper-right corner of the BatchPatch window you&#8217;ll see a small clock\/timer icon.  If it&#8217;s red, it&#8217;s disabled.  If it&#8217;s green, it&#8217;s enabled.  Click the icon to toggle it from enabled to disabled and vice versa.  If it&#8217;s disabled, no scheduled tasks will be executed at their configured run times, so make sure it&#8217;s enabled if you want your tasks to execute.<br \/>\n<br \/>\n<a href=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_36_58-new-1-BatchPatch.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_36_58-new-1-BatchPatch.png\" alt=\"\" width=\"649\" height=\"409\" class=\"aligncenter size-full wp-image-5358\" srcset=\"https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_36_58-new-1-BatchPatch.png 649w, https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_36_58-new-1-BatchPatch-300x189.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/a><\/p>\n<p><a href=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_37_12-new-1-BatchPatch.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_37_12-new-1-BatchPatch.png\" alt=\"\" width=\"649\" height=\"410\" class=\"aligncenter size-full wp-image-5359\" srcset=\"https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_37_12-new-1-BatchPatch.png 649w, https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_37_12-new-1-BatchPatch-300x190.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/a>\n<\/li>\n<h2 class=\"brownishOrange\">Optionally, send your grid to run in the BatchPatch service instance, so that scheduled tasks will be executed without BatchPatch needing to be open and without the computer needing to be logged-on<\/h2>\n<li>If you need\/want this grid&#8217;s scheduled tasks to execute without BatchPatch having to be open and\/or without the computer needing to be logged-on, you can send the grid to the BatchPatch service instance.  In this case, it won&#8217;t matter if your task scheduler icon is green or red (enabled or disabled) in the current instance of BatchPatch because in the service instance of BatchPatch, the task scheduler is always on\/enabled and cannot be turned off or disabled.  To send the grid to the BatchPatch service instance, right-click on the tab header and select &#8216;<em>Send grid to service instance<\/em>&#8216;, as illustrated in the screenshot below.<br \/>\n<\/p>\n<p><a href=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_46_20-new-1-BatchPatch.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_46_20-new-1-BatchPatch.png\" alt=\"\" width=\"649\" height=\"410\" class=\"aligncenter size-full wp-image-5367\" srcset=\"https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_46_20-new-1-BatchPatch.png 649w, https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_46_20-new-1-BatchPatch-300x190.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/a><\/p>\n<p>If the &#8216;<em>Send grid to service instance<\/em>&#8216; option is grayed out like it is in my screenshot, it means that the BatchPatch service instance is not installed.  If you would like to install it, follow the instructions in this posting: <a href=\"\/running-batchpatch-as-a-service\" title=\"Running BatchPatch as a Service\">Running BatchPatch as a Service<\/a><\/p>\n<p><a href=\"\/wp-content\/uploads\/2020\/11\/2020-11-19-14_51_46-.png\"><img loading=\"lazy\" decoding=\"async\" src=\"h\/wp-content\/uploads\/2020\/11\/2020-11-19-14_51_46-.png\" alt=\"\" width=\"649\" height=\"635\" class=\"aligncenter size-full wp-image-5365\" srcset=\"https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_51_46-.png 649w, https:\/\/batchpatch.com\/wp-content\/uploads\/2020\/11\/2020-11-19-14_51_46--300x294.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/a><\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Create a custom job queue Let&#8217;s start by creating our custom job queue. Select &#8216;Actions > Job Queue > Create\/modify job queue&#8216; In the Job Queue window, create your desired queue. In this case I have created a queue to execute an update + reboot cycle, indefinitely, until there are no more updates available to [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1,17,3],"tags":[99,273,439],"class_list":["post-5351","post","type-post","status-publish","format-standard","hentry","category-blog","category-general","category-tutorials","tag-job-queue","tag-scheduled-task","tag-update-reboot-cycle"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/posts\/5351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/comments?post=5351"}],"version-history":[{"count":12,"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/posts\/5351\/revisions"}],"predecessor-version":[{"id":5369,"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/posts\/5351\/revisions\/5369"}],"wp:attachment":[{"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/media?parent=5351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/categories?post=5351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/batchpatch.com\/wp-json\/wp\/v2\/tags?post=5351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}