Automated task for restarting a server out of hours
In some instances, you may need to restart your server unattended out of hours. Servers are normally fine to be kept running for long periods of time, but in some instances, restarts are recommended for several reasons:
Windows updates are pending, and the server requires restarting to install them.
Third party programs (e.g. Shadow Protect) requires re-installing and configuration that asks for the server to be re-started.
With some SQL backups, memory space becomes an issue. As part of my role performing Office IT support, I recently encountered an error with SQLBak not being able to backup SQL databases to Google drive. The error message was:
Failed to backup "xxxx" database with "Full" backup type: Database xxxx cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details. BACKUP DATABASE is terminating abnormally.
Consulting my previous helpdesk tickets with the same error, i was able to resolve the issue by restarting the server, after I diagnosed the error as low memory space (the cloud backup account still had 12 GB free space).
Any good cloud computing or Managed Services Company will prefer to restart any server out of production hours so as not to disrupt any users logged on to the server or using any files stored on the server.
To create an automated task to restart the server at say 9 pm, I would follow these steps:
Open Task Scheduler:
2. Right click and choose create basic task.
3. Enter task name and description and click on next.
4. Select a schedule. For this server restart, I recommend one off, and then just activate the task next time you need an out of hours restart scheduled.
5. Select " Start a Program" then "Next". Then Type "powershell" and for the arguments type “restart-computer” or “restart-computer -force” then click on “next”.
Click on finish and the task is complete. Don't forget to check in the morning before the office opens that the server is back online.