{"id":5727,"date":"2019-01-30T06:09:02","date_gmt":"2019-01-30T14:09:02","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=5727"},"modified":"2022-09-04T06:49:27","modified_gmt":"2022-09-04T13:49:27","slug":"restart-service-no-task-scheduler","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/restart-service-no-task-scheduler\/","title":{"rendered":"How to Make AlwaysUp Restart your Program Multiple Times per Day (without using the Task Scheduler)"},"content":{"rendered":"<div align=\"center\"><img decoding=\"async\" src=\"\/blog\/images\/stopwatch-225x225.png\" title=\"Restart your application multiple times per day\" alt=\"Restart your application multiple times per day\" border=\"0\" ><\/div>\n<p>Earlier this month, we presented <a href=\"\/blog\/alwaysup\/restart-service-regularly\/\">a couple of options for periodically restarting a temperamental legacy application with AlwaysUp<\/a>. You can either restart once per day (via a setting on the AlwaysUp Monitor tab) or multiple times per day (using the Windows Task Scheduler).<\/p>\n<p>Well, today we can offer you a third option &mdash; one that doesn&#8217;t rely on additional software, like the Task Scheduler.<\/p>\n<p>By leveraging the powerful <a href=\"\/products\/AlwaysUp\/Plugins\">Sanity Check<\/a> feature &mdash; which allows you to plug in your own failure detection system &mdash; we can get AlwaysUp to close and restart your program every few hours. <\/p>\n<p>Here is an example of how to set that up:<\/p>\n<h2 class=\"blog-caption\">Example: Restart OneDrive every 4 hours<\/h2>\n<p>For this example, we&#8217;ll work with Microsoft OneDrive &mdash; already <a href=\"\/products\/AlwaysUp\/Apps\/RunOneDriveAsAService.html\">installed as a Windows Service<\/a> on our Windows 10 machine.<\/p>\n<ol>\n<li>\n<p>First, create a simple batch file with these two commands:<\/p>\n<div class=\"highlight-box-green\" style=\"background:#f2f2f2;margin-top:20px;border: 1px dashed #4da6ff;\">\n@echo off<br \/>\nexit 1\n<\/div>\n<p>Save the file in your AlwaysUp installation folder, <b>C:\\Program Files (x86)\\AlwaysUp<\/b>. We have named our batch file &#8220;SignalRestartSanityCheck.bat&#8221;.<\/p>\n<\/li>\n<li>\n<p>Start AlwaysUp.<\/p>\n<\/li>\n<li>\n<p>Select <b>Application &gt; Edit\/View<\/b> to open OneDrive in AlwaysUp.<\/p>\n<\/li>\n<li>\n<p>Switch to the <b>Monitor<\/b> tab.<\/p>\n<\/li>\n<li>\n<p>Check the <b>Whenever it fails a &#8220;sanity check&#8221;<\/b> box mid-way down the page, and click the triple-dots button on the right:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/setup-sanity-check.png\" class=\"zoomPopup\" title=\"Setup Sanity Check\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/setup-sanity-check.png\" title=\"Setup Sanity Check (click to enlarge)\" alt=\"Setup Sanity Check\" border=\"0\" ><\/a><\/div>\n<\/li>\n<li>\n<p>In the window that comes up, enter the full path to the batch file you created in the <b>Run<\/b> field.<\/p>\n<p>And set the <b>Every<\/b> controls to 240 minutes (i.e. 4 hours):<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/configure-sanity-check-details.png\" class=\"zoomPopup\" title=\"Configure Sanity Check\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/configure-sanity-check-details.png\" title=\"Configure Sanity Check (click to enlarge)\" alt=\"Configure Sanity Check\" border=\"0\" ><\/a><\/div>\n<\/li>\n<li>\n<p>Confirm and save all your changes.<\/p>\n<\/li>\n<\/ol>\n<p>Now whenever we start OneDrive as a service with AlwaysUp button (or the computer is rebooted), this sequence will play out:<\/p>\n<ol>\n<li>\n<p>AlwaysUp starts OneDrive.<\/p>\n<\/li>\n<li>\n<p>After 4 hours have passed, AlwaysUp runs the batch file (sanity check).<\/p>\n<\/li>\n<li>\n<p>The batch file exits with 1, signaling to AlwaysUp that OneDrive should be stopped.<\/p>\n<\/li>\n<li>\n<p>AlwaysUp stops OneDrive.<\/p>\n<\/li>\n<li>\n<p>AlwaysUp restarts OneDrive (as specified on the Restart tab).<\/p>\n<\/li>\n<li>\n<p>And the cycle repeats&#8230; (go to step 2)<\/p>\n<\/li>\n<\/ol>\n<hr style=\"margin-top:40px\">\n<h2 class=\"blog-caption\">UPDATE: Automatically restart your application every 2, 4, 6, 8 or 12 hours &mdash; directly from AlwaysUp<\/h2>\n<p><a href=\"\/blog\/alwaysup\/version-11-8-released\/\">AlwaysUp version 11.8<\/a> introduced the ability to restart your application much more frequently.<\/p>\n<p>The new periods are available in the <b>Every<\/b> setting on the <b>Monitor<\/b> tab. Expand the drop-down to select the desired time frame:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/restart-application-frequently.png\" class=\"zoomPopup\" title=\"Restart your application more frequently\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/restart-application-frequently.png\" title=\"Restart your application more frequently (click to enlarge)\" alt=\"Restart your application more frequently\" border=\"0\"><\/a><\/div>\n<hr style=\"margin-top:30px\">\n<p style=\"margin-top:30px;\">Enjoy!<\/p>\n<!-- relpost-thumb-wrapper --><div class=\"relpost-thumb-wrapper\"><!-- filter-class --><div class=\"relpost-thumb-container\"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }<\/style><h3>You may also like...<\/h3><div style=\"clear: both\"><\/div><div style=\"clear: both\"><\/div><!-- relpost-block-container --><div class=\"relpost-block-container relpost-block-column-layout\" style=\"--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2\"><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/windows-event-logs-problem\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: Why isn&#039;t AlwaysUp Writing to the Windows Event Logs?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/qa-no-event-logs-150x150-1.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q&amp;A: Why isn&#039;t AlwaysUp Writing to the Windows Event Logs?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/run-batch-file-as-a-windows-service\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: How do I make AlwaysUp run my Batch File as a Windows Service?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/batch-file-windows-service-150x150-1.webp\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q&amp;A: How do I make AlwaysUp run my Batch File as a Windows Service?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/dropbox-software\/how-to-fix-opengl-problem\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Start Dropbox whenever your PC boots\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/dropbox-logo2-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">How to Fix the &quot;OpenGL&quot; Problem when Running Dropbox as a Windows Service<\/h2><\/div><\/div><\/a><\/div><!-- close relpost-block-container --><div style=\"clear: both\"><\/div><\/div><!-- close filter class --><\/div><!-- close relpost-thumb-wrapper -->","protected":false},"excerpt":{"rendered":"<p>Earlier this month, we presented a couple of options for periodically restarting a temperamental legacy application with AlwaysUp. You can either restart once per day (via a setting on the AlwaysUp Monitor tab) or multiple times per day (using the &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/restart-service-no-task-scheduler\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":5898,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[26,110,138],"class_list":["post-5727","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-alwaysup","tag-alwaysup-tag","tag-onedrive","tag-sanity-check"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=5727"}],"version-history":[{"count":2,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5727\/revisions"}],"predecessor-version":[{"id":11498,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5727\/revisions\/11498"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/5898"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=5727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=5727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=5727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}