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

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
timgreen7077

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
John

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 Favor

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).
ASKER
LockDown32

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
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.
John

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 Monk

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
LockDown32

@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.......
John

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.
ASKER
LockDown32

@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.....
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Phillip Monk

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).
ASKER
LockDown32

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 Monk

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
LockDown32

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

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 Rubin

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Dan

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.
ASKER
LockDown32

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
Dan

close, it's shutdown -r

hifin, not a forward slash
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
LockDown32

That is interesting. I am on a Windows 10 workstation and a shutdown ? yields using the slashes....
Dan

Ok, I learned something new, I guess you can do either....
Dan

question, are you autologgin in when it comes back up?  if not, maybee the right services arent starting.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Dan

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
ASKER
LockDown32

Not logging back in. It simply reboots and goes back to the ctrl-alt-del screen
ASKER
LockDown32

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.