ADSM-L

Re: [ADSM-L] Green issue: How to avoid leaving clients on all night

2009-04-22 00:07:21
Subject: Re: [ADSM-L] Green issue: How to avoid leaving clients on all night
From: Andrew Raibeck <storman AT US.IBM DOT COM>
To: ADSM-L AT VM.MARIST DOT EDU
Date: Wed, 22 Apr 2009 00:06:52 -0400
Well, you could try wrapping the "shutdown" program in a  script with some
intelligence behind it. I put a VBScript together fairly quickly on my XP
workstation and it seems to work okay (see below).

Notes:

* I tested on XP only, so you'll need to test on other Windows OSes.

* I use LocalSystem as the account for my scheduler service, in which case
I had to use the Services applet to configure the account to allow
interaction with my desktop. If I didn't do this, the Yes/No/Cancel prompt
did not show up on my system.

* When modifying the script or testing in your environment, if you want to
stop a shutdown and the script isn't doing the trick, issue "shutdown -a"
from a Windows OS prompt to stop the shutdown.

* In general I would not normally expect the results of this script to
otherwise have any bearing on the results of the scheduled operation that
is reported to the TSM server. Therefore I recommend using POSTNSCHEDULECMD
rather than POSTSCHEDULECMD. On my system, I put this in my options file:

   postnschedulecmd c:\my_vbscripts\shutitdown.vbs

* Use a "sane" delay value that gives your users a chance to cancel the
shutdown; for example, if they stepped away for a break.

* Note that if the TSM client is unable to immediately update the server
with the results of the scheduled event (for whatever reason, this is
hypothetical) and it needs to retry, your shutdown script might shut the
client down before the results can be reported back. As an alternative, you
could define a separate schedule with ACTION=COMMAND to invoke the shutdown
script; this schedule would run after the regular backup schedule.

* This is provided "as is", without warranty of any kind. Use at your own
risk. You can modify it for your needs, but make sure you test it
thoroughly before you deploy to avoid unexpected surprises from your users.

'=======================================================================
' shutitdown.vbs
' Author: Andrew M. Raibeck
'         storman AT us.ibm DOT com
'         Tivoli Storage Manager client development
'         IBM Corporation
'         (c) Copyright by IBM Corporation 2009. All Rights Reserved.
'
' This code is provided on an "as is" basis without warranty of any
' kind. Use is at your own risk. Test thoroughly in your environment
' before deploying.
'
' Adjust delay to appropriate value in seconds. Consider possibility that
' user may have stepped away for a few minutes and might not be able to
' respond right away, so maybe something like "delay = 1800" is more
' realistic.
delay = 60

' shutdown parameters:
'   -s means shutdown
'   -f means to force all running programs to close
'   -t means to delay the shutdown by the specified number of seconds
cmd = "shutdown -s -f -t " & delay

newline = Chr(13) & Chr(10)

msg = "The computer will shut down in " & delay & " seconds." & newline & _
      newline & _
      "Press Yes to shut down now." & newline & _
      "Press No to stop the shut down." & newline & _
      "Press Cancel to shut down at the end of the countdown"

title = "Daily shutdown prompt"

' Issue the shutdown command.
set objShell = Wscript.CreateObject("Wscript.Shell")
objShell.Run cmd, 1, True

' vbDefaultButton2 used to make "No" the default, in case user
' accidentally presses "ENTER" without seeing the message. This
' is probably the safest. vbSystemModal will force the Msgbox
' dialog to appear on top of the shutdown dialog.
confirmation = MsgBox(msg, _
                      vbYesNoCancel or vbDefaultButton2 or vbSystemModal, _
                      title)

if confirmation = vbYes then
   ' Abort the current shutdown, then initiate a new instant shutdown.
   set objShell = Wscript.CreateObject("Wscript.Shell")
   objShell.Run "shutdown -a", 2, True
   objShell.Run "shutdown -s -f -t 0", 2, True
elseif confirmation = vbNo then
   ' Abort the shutdown
   set objShell = Wscript.CreateObject("Wscript.Shell")
   objShell.Run "shutdown -a", 2, True
else
   ' Do nothing, just let the current shutdown command continue.
end if
'=======================================================================

Andy Raibeck
IBM Software Group
Tivoli Storage Manager Client Product Development
Level 3 Team Lead
Internal Notes e-mail: Andrew Raibeck/Tucson/IBM@IBMUS
Internet e-mail: storman AT us.ibm DOT com

IBM Tivoli Storage Manager support web page:
http://www.ibm.com/software/sysmgmt/products/support/IBMTivoliStorageManager.html


The only dumb question is the one that goes unasked.
The command line is your friend.
"Good enough" is the enemy of excellence.

"ADSM: Dist Stor Manager" <ADSM-L AT VM.MARIST DOT EDU> wrote on 2009-04-21
20:55:05:

> [image removed]
>
> Green issue: How to avoid leaving clients on all night
>
> Roger Deschner
>
> to:
>
> ADSM-L
>
> 2009-04-21 20:55
>
> Sent by:
>
> "ADSM: Dist Stor Manager" <ADSM-L AT VM.MARIST DOT EDU>
>
> Please respond to "ADSM: Dist Stor Manager"
>
> We're getting requests from a number of people who have their desktop
> computers (mix of Macs and Windows XP/Vista) backed up to TSM, for a way
> to avoid leaving them on all night.
>
> The issue is simple energy conservation. Even with the monitor off, and
> the disk drives spun down, a live PC still consumes quite a bit of
> electricity. If you put it into either Hibernate or Standby mode, the
> TSM Scheduler cannot run the backup.
>
> We had thought of setting a POSTSCHEDULECOMMAND of "shutdown", but that
> has a severe problem. What if you were working late, because of an
> urgent project, and backup ran. Your computer would then shut down
> without saving what you were working on, and precisely because it was
> urgent enough for you to be working on it late, this would be very
> valuable work that would be lost.
>
> Has anybody figured out a way around this basic problem?
>
> Roger Deschner      University of Illinois at Chicago     rogerd AT uic DOT 
> edu
> ==== "Research is what I'm doing when I don't know what I'm doing." ====
> ========================= -- Wernher von Braun =========================