At the time of writing this tutorial I owned a managed server running w2k. Th RDS was set-up by the supplier. Thankfully we have now moved all our servers away from them! ;-)
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
At the time of writing this tutorial I owned a managed server running w2k. Th RDS was set-up by the supplier. Thankfully we have now moved all our servers away from them! ;-)
The reason such a problem occured in the first place is because you do not have remote desktop/terminal services configured properly on your server. You have it configured so that disconnected sessions are terminated so that you do not end up locked out of your server when sesisons are left open.
Any CF hosting company worth their salt will not even enable CFEXECUTE on the server, even if it is sandboxed. The tut is aimed at those who own a dedicated box.
If you attempt to use the above scripts on a server you do not own / rent (dedicated) such as a shared server you may get yourself in trouble. Some ISP's who offer but don't understand the implications of the cfexecute tag leave there server unsecured enough for you to use them, but in doing so and rebooting the server they tend to get a little upset and consider it a violation of there AUP.
In previous version of windows (w2k) I have in the past used shutdown.exe (http://www.budja.com/shutdown/) in a simaler manner. Im not sure the above command works on w2k but using shutdown.exe does. -Randy