[THIN] Re: Reboot Terminal Server

  • From: lindaday@xxxxxxxxxxx
  • To: thin@xxxxxxxxxxxxx, <thin@xxxxxxxxxxxxx>
  • Date: Thu, 09 Nov 2006 03:54:46 +0000

I really appreciate your help.
Thanks,
Linda

-------------- Original message -------------- 
From: "Euan Cooper" <euan.cooper@xxxxxxxxxxxx> 

Easiest way is to write a reboot script and schedule it to run each night - or 
some other appropreate timing.  How often really depends on your environment - 
I use a staggered re-boot off all our production servers at half hour intervals 
starting at 1am each morning.

If you have Metaframe XP of higher you can schedule reboots from CMC but I 
still prefer a script as it allows me to do other housekeeeping stuff.


Below is my re-boot script which should give you the idea

-Ec

@echo off

::  REBOOT.CMD - Scripted process to reboot a Terminal Server - run via 
Schedule service
::  to reboot Metaframe servers at regular intervals.
::                Last Alterd by EJC - 3rd Oct 2003

:: This script uses SLEEP.EXE & NOW.EXE from the NT Resource kit
:: And BLAT.EXE (freeware command line SMTP mailer)
:: These files need to be somewhere in the path and BLAT will need to be 
installed as per
:: the documentation for this script to work correctly.


:: The script starts by checking that another Terminal server responds to a ping
:: If no response the server will not be re-booted.

:: The re-boot process starts by sending a message to any active users 
informing them 
:: that the server is about to be shutdown and gives them time to save their 
work and 
:: logoff. 

:: Once active users have had time to logoff the following processes are 
performed.
:: New logins are disabled
:: Disconnected sessions are logged off.
:: Active Sessions are logged off 
:: Any remaining sessions are reset
:: Spooler service is stopped
:: Spool directory is cleared
:: Log file of shutdown process is sent to admin account
:: Server is shutdown and re-booted

SetLocal
if  "%COMPUTERNAME%"=="MF1"     set @Check=MF4
if  "%COMPUTERNAME%"=="MF2"     set @Check=MF1
if  "%COMPUTERNAME%"=="MF3"     set @Check=MF2
if  "%COMPUTERNAME%"=="MF4"     set @Check=MF3
if  "%COMPUTERNAME%"=="MFTEST"  set @Check=MF1

if not "%@Check%"=="" goto Check

ECHO *************************************************************************  
                 >Shutdown.txt
Echo  Wrong Server - Reboot of %COMPUTERNAME% aborted                          
>>Shutdown.txt   
Echo.                                                                           
                                   >>Shutdown.txt  

 Blat shutdown.txt -t Administrator@xxxxxxxxxxxx -s "%COMPUTERNAME% Shutdown 
log"
 del Shutdown.txt

 GOTO :ExitBatch

:Check
 ping %@Check%|find /I "reply"
 if "%ERRORLEVEL%"=="0" goto Reboot

 ECHO ************************************************************************* 
                               >Shutdown.txt
 Echo  Server %@Check% not responding - Reboot of %COMPUTERNAME% aborted        
>>Shutdown.txt   
 Echo.                                                                          
                                                 >>Shutdown.txt  


 Blat shutdown.txt -t Administrator@xxxxxxxxxxxx -s "%COMPUTERNAME% Shutdown 
log"
 del Shutdown.txt
 
 
GOTO :EXitBatch

:?Check

:Reboot

%SystemDrive%
cd\

NOW Starting scheduled reboot of %COMPUTERNAME%        > Shutdown.txt
Echo.                                                                           
       >>Shutdown.txt

msg * This server will be Shutdown in 10 minutes - please finish work and logoff
sleep 300

Change logon /disable
msg * This server will be Shutdown in 5 minutes - please finish work and logoff
sleep 300

NOW Reboot of %COMPUTERNAME% initiated                 >>Shutdown.txt
Echo.                                                                           
   >>Shutdown.txt
msg *  Reboot Process on %COMPUTERNAME% initiated - Last chance to save your 
work!!!
Sleep 25

:: Logoff any Disconected sessions 
:: Details of any such sesions are written to the log so we can see any users 
who are not logging off properly
qwinsta | find "Disc" > disc.lst
Type disc.lst                                          >>Shutdown.txt
for /f "tokens=2" %%i in (disc.lst) do logoff %%i 
del disc.lst
Echo.                                                  >>Shutdown.txt   

:: Logoff any Active sessions
:: Details of any such sesions are written to the log so we can see if users 
are not logging off at night.
qwinsta|find "Active" > active.lst
Type active.lst                                        >>Shutdown.txt 
for /f "tokens=2" %%i in (active.lst) DO LOGOFF %%i 
del active.lst 

:: Clear any hung ICA sessions by re-settting ica-tcp
echo y|reset session ica-tcp 

:: Delete any orhpaned client printers
chgcdm /delete_client_printers

:stop Spooler Service wait 60 seconds for service to stop then clean up queues
net stop spooler                                       >>Shutdown.txt
sleep 60
del %windir%\system32\spool\printers\*.* /q /f


:: Delete temp files from Windows directory
del %windir%\*.tmp /s

Blat shutdown.txt -t Administrator@xxxxxxxxxxxx -s "%COMPUTERNAME% Shutdown log"
del Shutdown.txt
TSShutdn 2 /reboot /delay:2
Goto ExitBatch

:ExitBatch
:: Clear local environment Variables and Exit script
 ENDLOCAL

:?ExitBatch




-----Original Message-----
From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx]On Behalf Of 
lindaday@xxxxxxxxxxx
Sent: Thursday, 9 November 2006 4:28 p.m.
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Reboot Terminal Server 


I want to go to the cmd prompt and reboot the server and give a warning to the 
users on the system. How do you do that? How often should we reboot it? Would 
one time per day be too much or hurt the system?
Thanks,
Linda

Other related posts: