{"id":5248,"date":"2019-01-08T10:13:03","date_gmt":"2019-01-08T18:13:03","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=5248"},"modified":"2020-05-15T17:46:40","modified_gmt":"2020-05-16T00:46:40","slug":"restart-service-regularly","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/restart-service-regularly\/","title":{"rendered":"Q &#038; A: How do I Restart my Application\/Service Regularly from AlwaysUp?"},"content":{"rendered":"<div align=\"center\"><img decoding=\"async\" src=\"\/blog\/images\/qa-restart-application.png\" title=\"Q &#038; A - Restart Application\" alt=\"Q &#038; A - Restart Application\" border=\"0\" ><\/div>\n<div class=\"blog-qa-question-box\">\n<img decoding=\"async\" src=\"\/images\/quotes-transparent-21x21.png\">&nbsp;&nbsp;We are currently using <a href=\"\/products\/AlwaysUp\/\">AlwaysUp<\/a> with several executable instances. We need to have these restarted daily due to memory leaks from the application. <\/p>\n<p>I don&#8217;t see a scheduling restart option in AlwaysUp. I think this could be done through a windows task but I see that these are being run as windows services. Would you recommend doing this as a windows task or would the <a href=\"\/products\/ServiceProtector\/\">Service Protector<\/a> be a better option?<\/p>\n<p align=\"right\">&#8212; Kevan Hauver, <a href=\"https:\/\/northeast.aaa.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">AAA Northeast<\/a><\/p>\n<\/div>\n<p>Hi Kevan. Sorry to hear of the awful memory leaks!<\/p>\n<p>Yes, Service Protector could help your situation but there is no need to purchase that additional software. Here are a couple of options to restart your application periodically:<\/p>\n<h2 class=\"blog-caption\">Restart once daily (via the Monitor tab)<\/h2>\n<p>AlwaysUp makes it very easy to restart your application once per day, at a time of your choosing. Edit your application in AlwaysUp and look for the <b>Every<\/b> setting on the Monitor tab.<\/p>\n<p>Here is what the Monitor tab looks like when configured to restart the program every day at 2 AM (a time when the software\/server is likely to be &#8220;quiet&#8221;):<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/alwaysup-restart-daily-at-2am.png\" class=\"zoomPopup\" title=\"Restart every day at 2 AM\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/alwaysup-restart-daily-at-2am.png\" title=\"Restart every day at 2 AM (click to enlarge)\" alt=\"Restart every day at 2 AM\" border=\"0\" ><\/a><\/div>\n<p>Note that AlwaysUp can restart conditionally &mdash; only when one or more conditions are met. For example, to avoid restarting when the software is busy, check the <b>It has been idle for at least<\/b> box and fill in an appropriate duration.<\/p>\n<p>And if you find that simply restarting the application doesn&#8217;t clear the problem, you can try rebooting the entire machine. That option is available at the bottom of the form.<\/p>\n<div class=\"highlight-box-green\">\n<p><b>Update May 2019<\/b>: <a href=\"\/blog\/alwaysup\/version-11-8-released\/\">AlwaysUp version 11.8<\/a> added the ability to restart your application many times per day &mdash; every 2, 4, 6, 8 or 12 hours. You can still use the Task Scheduler as described below, but the new options (available on the Monitor tab) will be more convenient.<\/p>\n<\/div>\n<h2 class=\"blog-caption\">Restart multiple times per day (using the Windows Task Scheduler)<\/h2>\n<p>If restarting once per day is not enough, you have my sympathies!<\/p>\n<p>For that situation, we recommend creating a simple script that will restart your service and then enlisting the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Windows_Task_Scheduler\" target=\"_blank\" rel=\"noopener noreferrer\">Windows Task Scheduler<\/a> to restart the service as often as you like. Follow these steps, which you should be able to complete in 10 minutes or less:<\/p>\n<h3 class=\"larger\">Step 1: Create a batch file to restart your AlwaysUp service<\/h3>\n<p>First, please create a batch file that restarts your AlwaysUp service. It will contain two lines &mdash; one to stop the service and another to start it.<\/p>\n<p>For example, if your AlwaysUp application is named &#8220;Dropbox&#8221;, your batch file should contain the following calls to the <a href=\"\/blog\/windows-services\/essential-tools-for-windows-services-net-command\/\">Windows NET command<\/a>:<\/p>\n<pre style=\"background:#F4F4F4; padding: 10px;\">\r\n  NET STOP &quot;Dropbox (Managed by AlwaysUpService)&quot;\r\n  NET START &quot;Dropbox (Managed by AlwaysUpService)&quot;\r\n<\/pre>\n<p>The &#8221; (Managed by AlwaysUpService)&#8221; portion is a necessary part of the service&#8217;s name. All services created by AlwaysUp feature that suffix.<\/p>\n<div class=\"highlight-box-green\" style=\"background:#ffffe6;\">\n<p>Note: The batch file may not work as expected if it takes your application longer than 30 seconds to shut down. This is because NET STOP will only wait for 30 seconds before giving up. And if it does give up, the subsequent call to NET START will fail too. So after running the batch file, the AlwaysUp service may end up in the &#8220;Stopped&#8221; state &mdash; not what you want for your 24\/7 application!<\/p>\n<p>For slow applications, we recommend using our <a href=\"\/products\/ServicePilot\/\">free ServicePilot utility<\/a> instead of NET. ServicePilot can be configured to wait much longer than 30 seconds for the service to stop.<\/p>\n<p>Assuming that you have downloaded and saved ServicePilot to your AlwaysUp folder, here is what the batch file looks like with ServicePilot instead:<\/p>\n<pre style=\"background:#F4F4F4; padding: 10px;\">\r\n  \"C:\\Program Files (x86)\\AlwaysUp\\ServicePilot.exe\" -restart -wait 300 &quot;Dropbox (Managed by AlwaysUpService)&quot;\r\n<\/pre>\n<p>That command will wait for up to 300 seconds (5 minutes) for the service to restart.\n<\/p><\/div>\n<p>Give the batch file a meaningful name and save it to your AlwaysUp folder (C:\\Program Files (x86)\\AlwaysUp). We&#8217;ll need its full path in the next step.<\/p>\n<h3 class=\"larger\">Step 2: Setup the Task Scheduler to run the batch file<\/h3>\n<p>\nHere&#8217;s how to run the batch file (and restart your application) every day at noon.\n<\/p>\n<ol>\n<li>\n<p>\nStart Task Scheduler. This is best done by running <b>taskschd.msc<\/b> from a command prompt, or by opening the Control Panel, searching for &#8220;schedule&#8221; and clicking the Schedule tasks link:\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-task-scheduler.png\" class=\"zoomPopup\" title=\"Start Task Scheduler\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-task-scheduler.png\" title=\"Start Task Scheduler (click to enlarge)\" alt=\"Start Task Scheduler\" border=\"0\" width=\"520\" ><\/a><\/div>\n<\/li>\n<li>\n<p>\nOnce the Task Scheduler window appears, select <b>Create Basic Task<\/b> on the left:\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/windows-task-scheduler-create-basic-task.png\" class=\"zoomPopup\" title=\"Task Scheduler: Create Basic Task\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/windows-task-scheduler-create-basic-task.png\" title=\"Task Scheduler: Create Basic Task (click to enlarge)\" alt=\"Task Scheduler: Create Basic Task\" border=\"0\" width=\"520\" ><\/a><\/div>\n<\/li>\n<li>\n<p>\nIn the <b>Create Basic Task Wizard<\/b> window, enter a suitable name. You can leave the description blank.\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-name-description.png\" class=\"zoomPopup\" title=\"Enter a name for the task\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-name-description.png\" title=\"Enter a name for the task (click to enlarge)\" alt=\"Enter a name for the task\" border=\"0\" width=\"520\" ><\/a><\/div>\n<p>Click <b>Next<\/b> to proceed.<\/p>\n<\/li>\n<li>\n<p>\nThe <b>Daily<\/b> option (which we want) should already be selected, so click <b>Next<\/b> to move to the next screen:\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-daily.png\" class=\"zoomPopup\" title=\"Run the task daily\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-daily.png\" title=\"Run the task daily (click to enlarge)\" alt=\"Run the task daily\" border=\"0\" width=\"520\" ><\/a><\/div>\n<\/li>\n<li>\n<p>\nHere you specify the time to restart the service\/application. We have selected today at noon but you should select whatever time works for you.\n<\/p>\n<p>\nLeave <b>Recur every<\/b> at 1 day and click <b>Next<\/b> when you are ready to proceed.\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-time.png\" class=\"zoomPopup\" title=\"Specify the time to restart the application\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-time.png\" title=\"Specify the time to restart the application (click to enlarge)\" alt=\"Specify the time to restart the application\" border=\"0\" width=\"520\" ><\/a><\/div>\n<\/li>\n<li>\n<p>\nWe want to start a program (the default), so click <b>Next<\/b> to move on:\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-start-program.png\" class=\"zoomPopup\" title=\"Start a program\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-start-program.png\" title=\"Start a program (click to enlarge)\" alt=\"Start a program\" border=\"0\" width=\"520\" ><\/a><\/div>\n<\/li>\n<li>\n<p>\nClick the <b>Browse<\/b> button and choose the batch file you created in the previous step. Recall that we placed ours in the AlwaysUp folder (C:\\Program Files (x86)\\AlwaysUp):\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-program-path.png\" class=\"zoomPopup\" title=\"Select the batch file you created\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-program-path.png\" title=\"Select the batch file you created (click to enlarge)\" alt=\"Select the batch file you created\" border=\"0\" width=\"520\" ><\/a><\/div>\n<p>Click <b>Next<\/b> to proceed.<\/p>\n<\/li>\n<li>\n<p>\nThe basic configuration is now complete and you will see a summary of the scheduled task to be created.\n<\/p>\n<p>\nCheck the <b>Open the Properties dialog&#8230;<\/b> box and click the <b>Finish<\/b> button:\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/scheduled-task-summary.png\" class=\"zoomPopup\" title=\"Task summary\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/scheduled-task-summary.png\" title=\"Task summary (click to enlarge)\" alt=\"Task summary\" border=\"0\" width=\"520\" ><\/a><\/div>\n<\/li>\n<li>\n<p>\nAnd on this final screen, select the <b>Run whether user is logged in or not<\/b> option and check the <b>Run with highest privileges<\/b> box. These are required by Windows to manipulate the service on your behalf.\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/scheduled-task-properties.png\" class=\"zoomPopup\" title=\"Set task security\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/scheduled-task-properties.png\" title=\"Set task security\" alt=\"Set task security\" border=\"0\" width=\"520\" ><\/a><\/div>\n<p>\nClick <b>OK<\/b> to wrap up. (On some versions of Windows, you will have to enter the password for your account on the way out.)\n<\/p>\n<\/li>\n<li>\n<p>\nYour task is now fully configured. Navigate into the <b>Task Scheduler Library<\/b> on the left and confirm that all is well:\n<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/daily-restart-task-configured.png\" class=\"zoomPopup\" title=\"Daily restart task configured\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/daily-restart-task-configured.png\" title=\"Daily restart task configured (click to enlarge)\" alt=\"Daily restart task configured\" border=\"0\" width=\"520\" ><\/a><\/div>\n<\/li>\n<\/ol>\n<p>With this new task in place, Windows will automatically restart the AlwaysUp service every day at noon.<\/p>\n<h3 class=\"larger\">Step 3: Repeat the process to configure additional restarts<\/h3>\n<p>Want to restart again at 2 PM? Simply repeat the process to create another task but select 2 PM instead of noon.<\/p>\n<p>Advanced users can save a few clicks by exporting the task to a XML file, updating the file to specify a different time, and importing the modified XML to create a new task.<\/p>\n<p>Hopefully you don&#8217;t have to create too many tasks&#8230;<\/p>\n<p style=\"margin-top:30px;\">\n<b>Best of luck with your application!<\/b><\/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\/login-credentials\/\"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 Doesn&#039;t AlwaysUp Accept My Login Credentials?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/qa-trouble-entering-login-credentials-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: Why Doesn&#039;t AlwaysUp Accept My Login Credentials?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/how-dropbox-auto-upgrade-works\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"How Dropbox Auto-Upgrade Works\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/dropbox-logo-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 Dropbox Auto-Upgrade Works (and How to get AlwaysUp to Play Nice with it)<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/alwaysup-feature-spotlight-run-your-app-without-admin-rights\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"AlwaysUp Feature Spotlight: Run your App Without Admin Rights\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/windows-service-no-admin-rights-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\">AlwaysUp Feature Spotlight: Run your App Without Admin Rights<\/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>&nbsp;&nbsp;We are currently using AlwaysUp with several executable instances. We need to have these restarted daily due to memory leaks from the application. I don&#8217;t see a scheduling restart option in AlwaysUp. I think this could be done through a &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/restart-service-regularly\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3560,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[26,108,127,145,164],"class_list":["post-5248","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-alwaysup","tag-alwaysup-tag","tag-net-exe","tag-qa","tag-service-pilot","tag-task-scheduler"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5248","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=5248"}],"version-history":[{"count":2,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5248\/revisions"}],"predecessor-version":[{"id":9317,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/5248\/revisions\/9317"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/3560"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=5248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=5248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=5248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}