02 April 2012

ตั้งเวลาให้ Windows server reboot และ shutdown อัตโนมัติ


How do I schedule Windows Server Reboot / Shutdown?

You can download PsShutdown from sysinternals web site.
Store file on Windows server in folder. I use folder called C:\admutils. Next open windows command prompt (Start > Run > cmd) and use windows at command to schedule reboot:
c:> at 2:00am c:\admutils\psshutdown.exe -r -f -c -t 10
Above command will reboot system at 2am. If you want to shutdown system:
c:> at 1:00am c:\admutils\psshutdown.exe -s -f -c -t 10
Where,
  • -s: Shutdown windows server
  • -r: Reboot windows server
  • -f: Forces all running application to exit
  • -c: Allow the shutdown to by cancel by user
  • -t: Specifies the countdown in seconds until the shutdown
For more information read official psshutdown documentation. Read at command help by typing at /? command.

เพิ่มเติมครับ
Restart Windows Server 2003 from the command line

/?Displays the Help listing
/iDisplays the graphical user interface (GUI); it must be the first option
/lLogs off the current user; it cannot be used with the /d or /m options
/sShuts down the computer
/rShuts down and restarts the computer
/gShuts down and restarts the computer and then restarts any registered applications
/aAborts system Shutdown
/pTurns off the local computer with no timeout or warning
/hHibernates the local machine
/eDocuments the reason for shutting down the computer
/mSpecifies the target computer; it is used with \\computername
/t xxxWhere xxx is the number of seconds before Shutdown
/c “comment”Where “comment” is the reason for the Shutdown or restart
/fForces running applications to close without warning users
/d [p|u:]xx:yyProvides the reason for the Shutdown action: p = planned; u= unplanned; xx supplies the major reason code; yy = supplies the minor reason code

จากการทดสอบ ผมได้เพิ่มเข้าไปใน Scheduler Task
เริ่มจาก Add Scheduler Task ขึ้นมาใหม่ 
จากนั้นเลือกที่เป็น command Prompt ครับ
ตั้งชื่อ และ เลือกว่าจะให้ทำงาน ทุกวันหรือว่าวันใหน
จากนั้้นเลือกเวลาที่ต้องการครับ
ทำจนเสร็จแล้วเราจึงค่อยมาแก้ไข scheduler ที่เราสร้างขึั้นมา
ในช่อง Run แก้ให้มันเรียกไฟล์ shutdown ทำงาน
"c:\windows\system32\shutdown.exe /r /f /t 10"
เป็นอันเสร็จครับ 
^__^






No comments:

Post a Comment