| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Automatic restart - Windows server 2003
Hello everybody, do you know how can I set a plan to restart automatically my server 2003
I would like to restart it acordin to predefined plan. thanks in advance. |
|
#2
|
||||
|
||||
|
do you mean a restart of the server as in shutdown and reboot, or just a restart of all the services your system is running ?
if you want to automate your shutdown well thats easy using the "shutdown -s" command... but i know of now windows tool that lest you automatically boot up to a predefined time, unless you have another machine issue a boot call over the LAN and you have WakeOnLAN enabled in the Bios. or you can issue a reboot command and specify a particular delay. but i have not attempted this. see the scripts i have posted below and adapt them to your needs. See this link for more on using shutdown command in windows http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/TechRef/f411d38f-f139-49fa-9d6f-18befa5cb165.mspx the following is a part of script i use for server management. this part is used to restart my server. Code:
' ------ SCRIPT CONFIGURATION ------
strComputer = "<ServerName>" ' e.g. davidbeckham-01-svr
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colOS = objWMI.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
intRC = ObjOS.Reboot()
if intRC <> 0 then
WScript.Echo "Error attempting to reboot server: " & intRC
else
WScript.Echo "Rebooting server..."
end if
next
this part will allow me to set my startup delay to .. say ten second (for the below code) Code:
' ------ SCRIPT CONFIGURATION ------
strComputer = "." ' e.g. davidbeckham-srv-01
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colCompSys = objWMI.InstancesOf("Win32_ComputerSystem")
for Each objCompSys in colCompSys
WScript.Echo "Startup Delay Before: " & objCompSys.SystemStartupDelay
objCompSys.SystemStartupDelay = 10
objCompSys.Put_
WScript.Echo "Startup Delay After: " & objCompSys.SystemStartupDelay
next
you can use the following script to schedule the above portions of code on the server Code:
const MON = 1
const TUE = 2
const WED = 4
const THU = 8
const FRI = 16
const SAT = 32
const SUN = 64
' ------ SCRIPT CONFIGURATION ------
strComputer = "."
strCommand = "c:\perl\bin\perl.exe c:\scripts\diskchecker.pl"
strStartTime = "********013000.000000-240" ' 01:30 EDT
'YYYYMMDDHHMMSS.MMMMMM-/+TZO
boolRepeat = TRUE ' Repeat the task periodically
intWeekDay = SUN ' Repeat task every Sunday
intMonthDay = "" ' Set this if you want the task to repeat monthly
boolInteract = FALSE ' Do not interact with the desktop
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "")
set objNewTask = objWMI.Get("Win32_ScheduledJob")
intRC = objNewTask.Create(strCommand, _
strstartTime, _
boolRepeat, _
intWeekDay, _
intMonthDay, _
boolInteract, _
intJobID)
if intRC <> 0 then
Wscript.Echo "Error creating task: " & intRC
else
WScript.Echo "Successfully scheduled task."
WScript.Echo "JobID: " & intJobID
end if
i will look into writing a scirpt to handle a full/ all service restart.. but i'm pressed for time these days.. let me know if this helps. by the way: i usually refer to this book from Oriely: "Windows Server Cookbook" by Robbie Allen. very useful, and i have learned most of what i know from there. |
|
#3
|
|||
|
|||
|
Hello, thanks a lot for your replay, I will explain you axactly what is my problem.
From my web I send emails by asp script using CDONT or CDOSYS. Actualy I send the emails using cdont, the script works correct but the problem becames that after some time "one or two days" the emails are not send and stay on the pickup folder, and at the moment I restart the server, everything works OK and the emails that stay in the pickup folder are sent. Y have try to restar the smtp service only, but it does not work, it only works when I restart the server. Pls if you have any advice, let me know. Thanks again for your help. |
|
#4
|
||||
|
||||
|
ahh.. well now.. i know nothing about asp.. so the cdont and cdossys is greek to me.
i notified the mod over this .. thread, coz i think it does belong in the ISS forum. surely you shouldnt need to restart the server for what seems to be an ISS configuration issue.. or maybe and smtp - ISS problem will look into writing a script that will restart the ISS service, but i only use apache.. so this might take a while ... :shrugs: |
|
#5
|
||||
|
||||
|
David, you mean IIS and nope, it won't help since ASP can't perform any restart.
best would be to deal with the core of the problem... do you own the server? do you manage it and all the network? this may be network problem. anyways, worst case you can have some VB or C++ application that is doing the restart and schedule this on the server. |
|
#6
|
||||
|
||||
|
eh.. whats wrong with me.. why was i typing ISS ??
![]() darn.. needed sleep or coffee i guess... |
|
#7
|
||||
|
||||
|
lol that's ok... happens to the best of us!
![]() |
|
#8
|
|||
|
|||
|
Hello boys, thanks for replaying, I can manage the server by my self but I don' know as much about that.
But I can understant if you write some idea or solution for that. Pls try to replay me. Thanks. |
|
#9
|
||||
|
||||
|
hey mate.. whats your status.. did you ever manage to get this sorted out ?
|
|
#10
|
|||
|
|||
|
Anyone Listening?
Talk about resurecting a post...I was wondering what language those scripts are written in or if theres any additional programs or paths needed to make them work...
What I tried was dropping it into a .cmd file and running it after modifying the computer name and it doesn't like it... although to answer the original question a shutdown -r on win 2k3 will cause the system to reboot in 30 seconds... |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows OS > Automatic restart - Windows server 2003 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|