We help IT Professionals succeed at work.

What is the proper way to to automatically reboot a Windows Server?

LockDown32
LockDown32 asked
on
81 Views
Last Modified: 2018-09-02
I started this little venture maybe 15-20 years ago. All Windows Servers need to be rebooted every other week to keep them running right. I started out using a little utility called "Power Off" to schedule reboots on Sundays. It got to be too big of a pain. Mondays were horrible. The servers rebooted but there were several problems. Something about automatically rebooting that is different from the normal Start=>Shutdown=Restart. So many problems I gave up and went back to manually rebooting them.

   Fast forward 20 years.... I started using a MSP program called Ninja. It has a feature to reboot at a given time. I tried it and nothing has changed. Mondays are horrible. Backups don't run, VSS errors, DNS fails to start, etc, etc. The fix is the same. I have to to a Start=Shutdown=>Restart to get things working right again. So.... am I the only one that wants to automate the rebooting of Servers? Why isn't there a way to do an automated Start=>Shutdown=>Restart  when things actually come back properly?
Comment
Watch Question

Exchange Engineer
CERTIFIED EXPERT
Distinguished Expert 2018
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
JohnBusiness Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018

Commented:
We do not do this at all. Patch Tuesday comes Monthly without fail. We restart when we run updates. No need to do weekly restarts from my perspective.

And I would not use a third part to do this either.
David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Never, ever, ever... Power off a server...

When you do this, you're almost guaranteed to corrupt all your databases.

This means when database starts next, a recovery process must be done to attempt bringing all databases back to a working state.

This can add hours of time to your database restart.

Most databases will start + then corrupt table repair will begin. If you attempt to access a corrupt table before it's repaired, behavior is undefined.

There will be a similar command for your version of Windows servers.

Also, I only mentioned databases. If you kill power, likely many other subsystems will end up with corrupt data, especially if you're doing this on a regular basis.

Only do a normal system reboot/restart to cycle machines. Never a power off or shutdown now (kill all processes so they can't sync their memory data to disk).
LockDown32Owner
Top Expert 2016

Author

Commented:
I hate to say this but everyone is missing the question....

@TImgreen7077 the question wasn't what order to reboot them in. The question was how to "politely" reboot them with an automated routine.

@John the patching is automated and as you know after patching a reboot needs to be done. Once again the question is how to reboot a server "politely"

@David Favor I said nothing about powering off the server


Please focus on the question gents. Thanks.
timgreen7077Exchange Engineer
CERTIFIED EXPERT
Distinguished Expert 2018

Commented:
sounds like you already have an automated option, but if the servers come backup in the wrong order you can experience some of the issues you mentioned.
JohnBusiness Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018

Commented:
Once again the question is how to reboot a server "politely"

Log people off and close programs (databases) either by having users do it (during day) or closing databases at night and restarting that way.

We supervise restarts because things can happen.
Phillip MonkIT Manager

Commented:
I'd like to second what the above comments state. Servers are made to run all the time without the need for periodic restarts. If you are having issues with particular services failing after a period of time, that is a separate issue that needs to be resolved. However, I'm here to answer the question you posted.

I'd recommend using the Task Scheduler.

Create a basic task in Task Scheduler to trigger on the day and time of your choosing. in the "Action" section put in:
c:\windows\sytem32\shutdown /r

Open in new window

You can configure additional options (like running as the admin, regardless if they are logged in) in the Advanced Options.

Simpler is always better.
LockDown32Owner
Top Expert 2016

Author

Commented:
@TimGreen7077 100% of these sites are single server. If they were multi-server I could schedule which ones came up first but since 100% of these are single server sites it is moot.

    @John the questions also states I want to do this automated.......
JohnBusiness Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018

Commented:
We have several servers at a small number of sites and so supervised backups work well for us - just my experience here.

If I were automating it as you have done above, I would have it email me on a botched outcome (error code failure) so I could manage in advance of Monday Morning.
LockDown32Owner
Top Expert 2016

Author

Commented:
@Phillip Monk I will question your statement about servers being mean't to run forever. As John pointed out patch Tuesday comes along and some of those patches require a restart.....

So the shutdown /r will close databases, shut down programs and do things "politely"? in hopes of avoiding these oddities when the server comes back up?

I liken it to the APCC shutdown software (battery backup software in general). They seem to be able to shut things down "politely" before shutting down the server.....
Phillip MonkIT Manager

Commented:
Yes, 'shutdown /r' will give the signal to all running programs to terminate gracefully and will wait for their actions to be completed. It's identical to when you manually select the reboot option. I use it to restart remote servers when I'm logged in via RDC since you don't have that option (you are given "logout' instead).
LockDown32Owner
Top Expert 2016

Author

Commented:
The only thin I can find from the MSP on what their reboot does is:

Reboot

Utilizes WINAPI to run the'InitiateSystemShutdown' command.

Forced:
Adds the forced parameter, and executes after 5 seconds

Normal:
Does not add the forced parameter, and executes after 30 seconds.

So is the shutdown.exe and WINAPI the same thing? Based on the 30 seconds it appears to be. Is 30 seconds maybe not long enough?
Phillip MonkIT Manager

Commented:
A complete list of options and effects for shutdown.exe switches:
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/shutdown

I don't know of any difference between the WINAPI and the command line call. I would suspect they all call the same subsystem.

Normally the 30 second delay is to give any other users logged into the system a chance to save work. This command is universal across all Microsoft windows platforms. I know of no version of windows where this command does not apply. Again, I use this command on my production servers including my SQL servers when I'm remotely logged in.
LockDown32Owner
Top Expert 2016

Author

Commented:
That is interesting. I would agree it seems to be the same call. So.... I'll pick on SQL. It is a service isn't it? So the shutdown /r should shut down services gracefully? I somewhat tested it on a backup. The backup was running and the shutdown /r didn't stop it. So if the time (30 sec) is strictly to give users a chance to close and log off then all the services are shut down right before it reboots?
Qlemo"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015

Commented:
The shutdown will wait for services to stop. Only services not responding to the service manager are treated like applications not responding to Windows - and killed if using the force parameter. And that can cause corruptuon and data loss, of course.
Owen RubinConsultant

Commented:
DanOwner
CERTIFIED EXPERT

Commented:
can't you use the dos command shutdown?

task schedule as admin, then have a batch file like this

shutdown -r

that will restart the server.  Unless it's the same thing, it works for me, but I have limited needs.
LockDown32Owner
Top Expert 2016

Author

Commented:
That seems to be what I need to try. The MSP says it is doing a shutdown /r but things aren't rebooting right. Right now I have disabled the scheduled reboot altogether just to see if things work Monday. If they do I will bypass the MSP's reboot and try a shutdown /r
DanOwner
CERTIFIED EXPERT

Commented:
close, it's shutdown -r

hifin, not a forward slash
LockDown32Owner
Top Expert 2016

Author

Commented:
That is interesting. I am on a Windows 10 workstation and a shutdown ? yields using the slashes....
DanOwner
CERTIFIED EXPERT

Commented:
Ok, I learned something new, I guess you can do either....
DanOwner
CERTIFIED EXPERT

Commented:
question, are you autologgin in when it comes back up?  if not, maybee the right services arent starting.
DanOwner
CERTIFIED EXPERT

Commented:
I used Systernals auto login, and still do, I looked for a link to download it, and like all things Systernals, Microsoft bought it, some of their utilities they deleted, but It looks like autologin lived, and they changed it a bit.

https://docs.microsoft.com/en-us/sysinternals/downloads/autologon
LockDown32Owner
Top Expert 2016

Author

Commented:
Not logging back in. It simply reboots and goes back to the ctrl-alt-del screen
LockDown32Owner
Top Expert 2016

Author

Commented:
The MSP is doing something besides a simple shutdown /r. For now I have just removed the scheduled reboot to see it it is the source of the problem. If all the Monday morning problems go away I will script a shutdown /r.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.