Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Schedule automatic reboot

Status
Not open for further replies.

Leenie

Technical User
Jan 17, 2003
306
CA
I know this is probably very easy, but can someone tell me how to schedule an automatic reboot of the server for, say, every Sunday afternoon (when we're closed)?

Thanks.

Colleen Gayle Lane
Milton Public Library
 
Okay, I think I understand. I create a batch file with "shutdown /L /R /Y /C" in it and call it reboot.cmd (or something else). But, I'm not sure what the AT command would be to run that batch file every Sunday or if possible, actually, just the first Sunday of every month?

Colleen Gayle Lane
Milton Public Library
 
Okay, I've played with this on my own XP PC and it basically works. However, it only seems to like the command "shutdown /L /R". If I add the /Y /C it won't run. Do you think it's because I'm on XP. Maybe on the server it will need the /Y /C. But I can't play with the server right now.

Colleen Gayle Lane
Milton Public Library
 
Okay, I set the reboot.cmd to run at 8:00 this morning. Now, here's a stupid question. How can I tell whether the server actually rebooted. Is it in the event viewer or something? I know the task ran but that doesn't necessarily mean that the reboot happened successfully. Thanks.

Colleen Gayle Lane
Milton Public Library
 
You will see lots of service activity around that time in the system event log.
 
You can also get the psuptime.exe utility from the same sysinternals site and run it in the morning. It will tell you how long your system has been up.
 
Thanks for that info. I used systeminfo from the command prompt and sure enough the server has been up and running for 7 days+ so the daily restarts I've been trying obviously are not happening. It works on my XP machine but not on the 2003 server. So, I must have something wrong in the batch file.

Colleen Gayle Lane
Milton Public Library
 
Hmmm i haven't used it on a 2003 server there might be an issue with the box that pops up asking for a reason for the reboot.
 
Yeah, that's what I was thinking. Monday morning which is a good time for me to play around with the server I am going to run the batch file manually and see what pops up. If it reboots no problem, then I'm thinking it might be because the server is locked once the screen saver comes on which I read about here: (
However that problem is supposed to be fixed with SP1 which we have installed. So, I dunno.

Colleen Gayle Lane
Milton Public Library
 
Make sure the task scheduler is running on an account that has enough rights to run the commands you're using in the .cmd file. Usually the scheduler runs under the system account which should be ok.
 
another thing you can try it to set a delay in the command so it waits like 300 seconds. I think the switch may be /t. Anyway, once you prove it works, just do a shutdown /a, which will abort the command.
 
Okay. This morning I ran the reboot.cmd manually which contains only "shutdown /r". And the system rebooted. So I set up the task to run that command at 8:00 tomorrow morning. I was logged in as the administrator and entered the password twice when prompted by the task scheduler so we'll see what happens tomorrow morning.

Colleen Gayle Lane
Milton Public Library
 
ok, so if you have the task setup to run as an admin or backup operator, it should work fine.

Also remember, you can always check tyhe job by right-clicking the task ans select "RUN NOW".
 
I just setup a simple scheduled task, pointed to shutdown.exe, then after configuring the schedule, opened the task and changed the command to:

C:\WINDOWS\system32\shutdown.exe -r -f -c "Daily reboot"

The task is run by a user with domain admin rights, and the job runs successfully on about 15 of our servers, daily.

You can tell whether it was successful by opening up task scheduler and scrolling to the right and checking the code under Last Result. 0x0 means it was successful.

Hope this helps!
Brent
 
Okay. First thing this morning at 9:00 I checked systeminfo at the command prompt and the server had been up and running for 23 hours so it did not reboot at 8:00 this morning. Even though the task scheduler says it ran at 8:00 and will run again at 8:00 tomorrow morning. In the last result the info is 0x4f7 (whatever that means) not 0x0. Then at about 9:05 the server did reboot. I think it could not run the command 8:00 because the server was locked until I came in at 9:00 and did Ctrl-Alt-Del and entered the password. This was supposed to be fixed in SP1 I thought.

Colleen Gayle Lane
Milton Public Library
 
In the task scheduler, click the 'advanced" button and view the log. This will give you more detail about what happened to the job. What account was the task scheduled under? Was it the default of system?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top