Avatar of LockDown32
LockDown32Flag for United States of America

asked on 

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

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?
Windows OS

Avatar of undefined
Last Comment
LockDown32
ASKER CERTIFIED SOLUTION
Avatar of timgreen7077
timgreen7077

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of John
John
Flag of Canada image

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.
Avatar of David Favor
David Favor
Flag of United States of America image

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).
Avatar of LockDown32
LockDown32
Flag of United States of America image

ASKER

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.
Avatar of timgreen7077
timgreen7077

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.
Avatar of John
John
Flag of Canada image

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.
Avatar of Phillip Monk
Phillip Monk
Flag of United States of America image

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.
Avatar of LockDown32
LockDown32
Flag of United States of America image

ASKER

@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.......
Avatar of John
John
Flag of Canada image

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.
Avatar of LockDown32
LockDown32
Flag of United States of America image

ASKER

@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.....
Avatar of Phillip Monk
Phillip Monk
Flag of United States of America image

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).
Avatar of LockDown32
LockDown32
Flag of United States of America image

ASKER

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?
Avatar of Phillip Monk
Phillip Monk
Flag of United States of America image

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.
Avatar of LockDown32
LockDown32
Flag of United States of America image

ASKER

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?
Avatar of Qlemo
Qlemo
Flag of Germany image

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.
Avatar of Dan
Dan
Flag of United States of America image

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.
Avatar of LockDown32
LockDown32
Flag of United States of America image

ASKER

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
Avatar of Dan
Dan
Flag of United States of America image

close, it's shutdown -r

hifin, not a forward slash
Avatar of LockDown32
LockDown32
Flag of United States of America image

ASKER

That is interesting. I am on a Windows 10 workstation and a shutdown ? yields using the slashes....
Avatar of Dan
Dan
Flag of United States of America image

Ok, I learned something new, I guess you can do either....
Avatar of Dan
Dan
Flag of United States of America image

question, are you autologgin in when it comes back up?  if not, maybee the right services arent starting.
Avatar of Dan
Dan
Flag of United States of America image

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
Avatar of LockDown32
LockDown32
Flag of United States of America image

ASKER

Not logging back in. It simply reboots and goes back to the ctrl-alt-del screen
Avatar of LockDown32
LockDown32
Flag of United States of America image

ASKER

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.
Windows OS
Windows OS

This topic area includes legacy versions of Windows prior to Windows 2000: Windows 3/3.1, Windows 95 and Windows 98, plus any other Windows-related versions including Windows Mobile.

129K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo