The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation

How to Make AlwaysUp Restart your Program Multiple Times per Day (without using the Task Scheduler)

Restart your application multiple times per day

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 Windows Task Scheduler).

Well, today we can offer you a third option — one that doesn’t rely on additional software, like the Task Scheduler.

By leveraging the powerful Sanity Check feature — which allows you to plug in your own failure detection system — we can get AlwaysUp to close and restart your program every few hours.

Here is an example of how to set that up:

Example: Restart OneDrive every 4 hours

For this example, we’ll work with Microsoft OneDrive — already installed as a Windows Service on our Windows 10 machine.

  1. First, create a simple batch file with these two commands:

    @echo off
    exit 1

    Save the file in your AlwaysUp installation folder, C:\Program Files (x86)\AlwaysUp. We have named our batch file “SignalRestartSanityCheck.bat”.

  2. Start AlwaysUp.

  3. Select Application > Edit/View to open OneDrive in AlwaysUp.

  4. Switch to the Monitor tab.

  5. Check the Whenever it fails a “sanity check” box mid-way down the page, and click the triple-dots button on the right:

    Setup Sanity Check
  6. In the window that comes up, enter the full path to the batch file you created in the Run field.

    And set the Every controls to 240 minutes (i.e. 4 hours):

    Configure Sanity Check
  7. Confirm and save all your changes.

Now whenever we start OneDrive as a service with AlwaysUp button (or the computer is rebooted), this sequence will play out:

  1. AlwaysUp starts OneDrive.

  2. After 4 hours have passed, AlwaysUp runs the batch file (sanity check).

  3. The batch file exits with 1, signaling to AlwaysUp that OneDrive should be stopped.

  4. AlwaysUp stops OneDrive.

  5. AlwaysUp restarts OneDrive (as specified on the Restart tab).

  6. And the cycle repeats… (go to step 2)

UPDATE: Automatically restart your application every 2, 4, 6, 8 or 12 hours — directly from AlwaysUp

AlwaysUp version 11.8 introduced the ability to restart your application much more frequently.

The new periods are available in the Every setting on the Monitor tab. Expand the drop-down to select the desired time frame:

Restart your application more frequently


Posted in AlwaysUp | Tagged , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *