Summary:
This tutorial will tell you how to reboot your server without even logging in.
Tutorial:
I was faced with a dilemma this weekend. I had a crash on my cable connection as I was connected to my dedicated server using Remote Desktop Connection. This meant that that when I went to log back in to the server, I couldn’t as the maximum number of remote sessions had been reached.
So. No access to the OS to reboot. It’s a Sunday so the support teams couldn’t reboot the server for me. Ring the data centre? No chance. What to do? After panicking for about 15 minutes and a quick chat with Pablo on MSN, where this idea spawned from, I wrote a very simple script to reboot the server.
To run this script you need to have CFEXECUTE enabled for your domain which if you own the server is not really an issue!!!
There is a command line instruction called tsshutdn.exe on Windows machines and servers. This command can be used for a number of things including rebooting the server. Here’s the command with the available parameters:
TSSHUTDN [wait_time] [/SERVER:servername] [/REBOOT] [/POWERDOWN]
[/DELAY:logoffdelay] [/V]
wait_time - Seconds to wait after user notification before terminating all user sessions (default is 60).
/SERVER:servername The server to shut down (default is current).
/REBOOT Reboot the server after user sessions are terminated.
/POWERDOWN The server will prepare for powering off.
/DELAY:logoffdelay Seconds to wait after logging off all connected
sessions (default is 30).
/V Display information about actions being performed.
All I wanted to do was reboot the server so in notepad I wrote the following:
Tsshutdn.exe 0 /reboot /delay:0
Save this file as reboot.bat. A bat file is simply a set of instructions normally run from the command prompt. The above instruction translates to “Reboot the server with 0 seconds delay”
Now we just needed to execute this command on the server. Upload you reboot.bat file to your server.
Create a new CFML file and call it reboot.cfm or whatever. Within the body tags for that file add the lines:
<cfexecute name = "c:\inetpub\yoursite\wwwroot\reboot.bat" timeout = "20">
</cfexecute>
You will need to replace "c:\inetpub\yoursite\wwwroot\reboot.bat" with the physical path to the BAT file on your web server.
Now simply use your browser and go to http://www.yourdomain.com/reboot.cfm and the server will reboot.
This is obviously quite a drastic measure and should only be done in extreme circumstances where a reboot is the only answer and I take NO RESPONSIBILITY WHATSOEVER IF YOU BREAK YOUR SERVER!
Submitted by: Phil Williams
Email: support@openmindhosting.com
Site: http://www.openmindhosting.com