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.
First, create a simple batch file with these two commands:
@echo off
exit 1Save the file in your AlwaysUp installation folder, C:\Program Files (x86)\AlwaysUp. We have named our batch file “SignalRestartSanityCheck.bat”.
Start AlwaysUp.
Select Application > Edit/View to open OneDrive in AlwaysUp.
Switch to the Monitor tab.
Check the Whenever it fails a “sanity check” box mid-way down the page, and click the triple-dots button on the right:
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):
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:
AlwaysUp starts OneDrive.
After 4 hours have passed, AlwaysUp runs the batch file (sanity check).
The batch file exits with 1, signaling to AlwaysUp that OneDrive should be stopped.
AlwaysUp stops OneDrive.
AlwaysUp restarts OneDrive (as specified on the Restart tab).
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:
Enjoy!