Results 1 to 4 of 4
  1. #1
    Newcomer
    Join Date
    Mar 2006
    Location
    Austin, TX
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question How to use IF statement along with day of week in TSM script?

    Hey all!

    I have recently migrated from an AIX TSM instance to Windows TSM. I'm now converting all my AIX scripts to TSM scripts where possible, but can't find a lot of documentation on how to apply logic within TSM scripts.

    So, on my daily maintenance script, I'd like to backup storage pools, run a DB backup, run a prepare and then eject DRM tapes on weekdays. Something like:

    if (??day of week is Saturday or Sunday??) goto expire
    q drm t* wherestate=mountable > /path/file
    move drm t* wherestate=mountable remove=bulk tostate=vault
    expire: expi i
    exit

    Can anyone show how to accomplish the ??day of week is Saturday or Sunday?? part of this? Any pointers to better docs/guides for TSM scripting would also be much appreciated!

    Otherwise, I figure I'll just have to have a script scheduled for Mon-Fri and a script without the DRM statements scheduled for Sat-Sun.

    Thanks in advance,
    TMan

  2. #2
    Moderator chad_small's Avatar
    Join Date
    Dec 2002
    Location
    Gilbert, AZ
    Posts
    2,194
    Thanks
    1
    Thanked 26 Times in 25 Posts

    Default

    TSM scripts have limited logic processing. It would be easier to create the two separate scripts and schedule them accordingly.
    Chad Small
    IBM Certified Deployment Professional
    chadsmal@gmail.com
    http://www.tsmadmin.com

  3. The Following User Says Thank You to chad_small For This Useful Post:

    TMan (07-31-2012)

  4. #3
    Senior Member
    Join Date
    Dec 2004
    Location
    NC
    Posts
    200
    Thanks
    0
    Thanked 12 Times in 11 Posts

    Default

    TSM scripts are very limited but you can do the following with your example (days of week start with Sunday as 1)

    select server_name from status where dayofweek(current_timestamp) in (7,1)
    if(rc_ok) goto expire
    q drm t* wherestate=mountable > /path/file
    move drm t* wherestate=mountable remove=bulk tostate=vault
    expire: expi i
    exit

    More generally you can do stuff like this

    select server_name from status where dayofweek(current_timestamp)=1
    if(rc_ok) goto Sunday
    select server_name from status where dayofweek(current_timestamp)=2
    if(rc_ok) goto Monday
    select server_name from status where dayofweek(current_timestamp)=3
    if(rc_ok) goto Tuesday
    ...
    etc etc etc
    select server_name from status where dayofweek(current_timestamp)=7
    if(rc_ok) goto Saturday
    /* technically next line not needed but ... */
    goto Exit
    Monday:
    ....
    goto Exit
    Tuesday:
    ...
    goto Exit

    etc etc etc
    Exit:
    exit

    I like to use constructs like this to get windows within a day
    select server_name from status where hour(current_time) not in (12,13,14,15)
    if(rc_notfound) goto exit
    ...

    or to check if a process is already running before starting
    select * from processes where process='Reclaim Storage Pool' and status like '%TAPEPOOL%'
    if(rc_notfound) backup stg mesgdisk mesgcopy maxpr=$1

    I don't have any docs or links though, just trial and error. And they can get pretty ugly so moderation is the key. And you might want to use calls to scripts using the run command to keep any single script reasonable to read.
    "If we knew what it was we were doing, it would not be called research, would it?" -- Albert Einstein

  5. The Following 2 Users Say Thank You to rmazzon For This Useful Post:

    mguery (08-02-2013),TMan (07-31-2012)

  6. #4
    Newcomer
    Join Date
    Mar 2006
    Location
    Austin, TX
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Great example rmazzon - Thanks!

    In reading about the IF in TSM, it does look to be really limited. That really hurts my feelings coming from AIX/kornshell scripting.

    The extra examples are also appreciated. My previous script for starting reclamation would get the current time and do a simple subtraction to give "recl stg" a duration. But with the example you gave to see if a process is running, I'll just schedule the reclamation to start, have it check for processes which _should_ be finished (like stg pool backups or DB backups) and run for a predetermined amount of time.

    Off to experiment!

    Thanks again,
    TMan

Similar Threads

  1. Day to day tasks of a TSM Administrator
    By jssanche in forum Backup / Archive Discussion
    Replies: 2
    Last Post: 12-04-2013, 06:53 AM
  2. script to fine out the nodes access per day.
    By khawts in forum Scripting
    Replies: 3
    Last Post: 06-22-2010, 12:06 AM
  3. Select script to display tapes used per week
    By HiteshPP1974 in forum Scripting
    Replies: 5
    Last Post: 04-24-2007, 04:40 PM
  4. Replies: 5
    Last Post: 03-26-2007, 02:40 PM
  5. Script to list volumes sent Offsite by day?
    By Stephan in forum Scripting
    Replies: 6
    Last Post: 02-13-2007, 09:35 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •