1. Community Tip: Please Give Thanks to Those Sharing Their Knowledge.
    If you receive helpful answer on this forum, please show thanks to the poster by clicking "LIKE" link for the answer that you found helpful.
  2. Community Tip: Forum Rules (PLEASE CLICK HERE TO READ BEFORE POSTING)
    Click the link above to access ADSM.ORG Acceptable Use Policy and forum rules which should be observed when using this website. Violators may be banned from this website. This notice will disappear after you have made at least 3 posts.

Script to cancel all process

Discussion in 'Scripting' started by barouch, May 15, 2007.

  1. barouch

    barouch ADSM.ORG Member

    Joined:
    Apr 23, 2007
    Messages:
    14
    Likes Received:
    0
    Hello all
    i need a script to Stop ALL procees , before night backups.
    Especially process that occupied tapes drive.
    please advice
    thanks
    bb
    Z101@il.ibm.com :confused:
     
  2.  
  3. moon-buddy

    moon-buddy ADSM.ORG Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,814
    Likes Received:
    358
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    The difficulty of writing a script that stops processes that is task specific is knowing what task TSM is running at a point in time, and the process number.

    One technique is to search for key words that you know corresponds to a tape related process. Let us say TSM is running Space Reclamation. If you do a "q proc", you will see all the process that are running and one would be "Space Reclamation".

    722 Space Reclamation Volume A12345L2 (storage pool LTOPOOL) ...

    The number before "Space Reclamation" is the process number which you are interested about.

    If you write a script like:

    dsmadmc -id=userid -password=user_password -dataonly=yes "q proc" | grep "Space Reclamation" | awk '{print $1}'

    you will end up with 722 as a result, and for which corresponds to the process number you need to cancel.

    To complete the script:

    PROC=`dsmadmc -id=userid -password=user_password -dataonly=yes "q proc" | grep "Space Reclamation" | awk '{print $1}'`

    dsmadmc -id=userid -password=user_password -dataonly=yes "cancel proc $PROC"

    This would be a good starting point. You can create a list of known processes that is tape specific and cancel one-by-one listed processes using these two lines of script.

    This is one way.
     
    Last edited: Mar 9, 2017
  4. PJ

    PJ ADSM.ORG Senior Member

    Joined:
    Nov 18, 2005
    Messages:
    1,071
    Likes Received:
    4
    Location:
    LU Germany
    dsmadmc -se=myserver -id=myadmin -pa=mypw -dataonly=yes "select process_num from processes" |while read procnum
    do
    dsmadmc -se=myserver -id=myadmin -pa=mypw can proc ${procnum}
    done
     
  5. baldomero83

    baldomero83 ADSM.ORG Member

    Joined:
    Feb 7, 2007
    Messages:
    84
    Likes Received:
    0

    try to use the duration parameter in your administrative scheduling for server process (migration, stgp backup, reclamation) . I think is basically an scheduling exercise , try to make sure your migration , backup stgp and reclamations are completed b4 the next day's cylce.
    having to stop processes -either manually or scripted means that you have'nt really put time to check the schedulings..
     
  6. n9hmg

    n9hmg ADSM.ORG Senior Member

    Joined:
    Dec 18, 2006
    Messages:
    602
    Likes Received:
    13
    Occupation:
    unix admin
    Location:
    northern front-range Colorado, USA
    for process in `dsmadmc -id=$user -pass=$pass -tab select process_num from processes |grep ^[1-9]`
    do
    dsmadmc -id=$user -pass=$pass cancel process $process
    done

    I'll leave it to you to populate the user and pass variables.
     
  7. tsmtodd

    tsmtodd ADSM.ORG Member

    Joined:
    May 17, 2005
    Messages:
    79
    Likes Received:
    2
    IBM needs to implement an "end_time" parm. Duration doesn't work well when you have a varying start time.
    reclaim stgpool <stgpoolname> thre=60 stopdate=today stoptime=17:00 would be great! Too bad it doesn't exist.
     
  8. PJ

    PJ ADSM.ORG Senior Member

    Joined:
    Nov 18, 2005
    Messages:
    1,071
    Likes Received:
    4
    Location:
    LU Germany
    Yep... agreed - or at least a "can pr all" similar to "can se all".

    PJ

    (or you return to good old threshold driven migration and reclamation, which should fix your particular problem, too)
     
    Last edited: May 16, 2007
  9. mateinone

    mateinone ADSM.ORG Moderator

    Joined:
    Nov 21, 2005
    Messages:
    537
    Likes Received:
    2
    Occupation:
    TSM Specialist
    Location:
    Victoria, Australia
    whilst you can write a script to kill all processes, if you want to effectively end everything cleanly, then a cancel proc xxx for each device is not an effective way to end things.

    It is ineffective in cancelling expirations, migrations and reclamations.

    What OS are you currently running?

    also are all of your storage pool migrations set at the same level when not migrating???

    for example hi=90 lo=80 ???
     
    Last edited: May 16, 2007
  10. barouch

    barouch ADSM.ORG Member

    Joined:
    Apr 23, 2007
    Messages:
    14
    Likes Received:
    0
    cancel all procees

    Thank you all for your help !!
    But nothing works!!!
    The TSM is a WIN2003 server ,
    A special need to stop at Least the reclamation process.
    All other process usually not bother ...
    there is no such command : CANCEL PROC ALL !!!! (TSM 5.3.x) .
    Thanks
    And please advice
    bb
     
  11. mateinone

    mateinone ADSM.ORG Moderator

    Joined:
    Nov 21, 2005
    Messages:
    537
    Likes Received:
    2
    Occupation:
    TSM Specialist
    Location:
    Victoria, Australia
    I will take a look later today if no one has created something in the meantime.
    However i need to know if you want to set your recs and your stgpools back to a certain thresholds.

    As mentioned, they are not going to do a can pr all. Because you would effectively have to reset pools to 100-99 and recs to 100 to pretty well guarantee that you were effectively stopping, if it was an out of the box script.

    Anyway,

    let me know your preferred thresholds and will see what I can do... would prefer it was bloody AIX though :p
     
  12. chad_small

    chad_small ADSM.ORG Moderator

    Joined:
    Dec 17, 2002
    Messages:
    2,240
    Likes Received:
    49
    Occupation:
    AIX/SAN/TSM
    Location:
    Gilbert, AZ
    Canelling any reclaim or migration does not "KILL" the process immediately. TSM works by transaction points so it continues the process until the next transaction point and then closes out the process. This frustrates the hell out of a lot of admins, but it keeps data ingetrity and don't expect it to change. If you need to cancel a process by a certain time you need to give yourself some buffer time to allow the processes to finish and do cleanup before the stop.
     
  13. moon-buddy

    moon-buddy ADSM.ORG Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,814
    Likes Received:
    358
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    Since your TSM server is Windows based, try the batch file below:

    ------------------------------------------------------------------------------------
    @echo off
    IF EXIST OUT DEL OUT

    dsmadmc -id=USERID -password=PASSWORD "q process" | findstr "Space Reclamation" | awk '{print $1}' > IN

    GSAR -s, -r -f IN OUT

    IF NOT EXIST OUT (
    COPY IN OUT
    ) ELSE (
    ECHO > NUL
    )

    for /F %%i in (OUT) do dsmadmc -id=USERID -password=PASSWORD "cancel process %%i"
    -------------------------------------------------------------------------------------

    As I mentioned before, you can create a list that is "tape process" specific and process through the list.

    Google for GSAR and awk. These are windows based UNIX-equivalent commands that you have to place in c:\windows\system32

    Works well for me. The batch file you have to create must be in c:\Program Files\Tivoli\TSM\baclient.
     
    Last edited: May 17, 2007
  14. rulan

    rulan ADSM.ORG Member

    Joined:
    Jan 23, 2008
    Messages:
    20
    Likes Received:
    1
    What should i use to cancel multiple processes.
    I need to kill 3 processes at 5:00pm daily and I want to script it. With the help of this blog -- i can kill one process but not more than one. Can someone please help with that part of the script.
     
  15. n9hmg

    n9hmg ADSM.ORG Senior Member

    Joined:
    Dec 18, 2006
    Messages:
    602
    Likes Received:
    13
    Occupation:
    unix admin
    Location:
    northern front-range Colorado, USA
    rulan: Every example I've read (except MoonBuddy's first example, which was plainly a demo of how to get and cancel a single process, suitable for modification into your own scripting environment) cancels all processes.

    Chad managed to get dos to do it in the post directly above yours. Further up, I do it with unix shell syntax using a for loop. Directly above that PJ does the same with a while loop(though not in a way I'd trust), and even mine left off discarding the stupid commas.
    If you expect it to happen in pure tsm scripting, your expectation is going to go unmet.... at least in classic TSM. the db2 stuff in 6.1 probably lets you do some pretty flexible things.

    You'll need to learn the rudiments of a scripting environment to understand the examples above, and to implement them for your own. I believe somebody's written perl modules for TSM. I personally was in too big a hurry and just scripted directly against the dsmadmc, using bourne syntax. MoonBuddy's wintel example above is impressive. When I've got to work from windows, I set up cygwin and use a real operating environment.
     
  16. tmmckinn

    tmmckinn ADSM.ORG Member

    Joined:
    Jun 1, 2006
    Messages:
    39
    Likes Received:
    0
    Occupation:
    SAII City of Wichita
    Location:
    Wichita
    Process priority should be at play here. If you need reclamation to make way for backups, the tsm server should give priority to the backup processes if tape resources are needed. If TSM deems it necessary, reclamation should be preempted for bacukps (I know this works for restore processes preempting reclamation processes).

    If I read the documentation right, your server should process priority for resource clashes if preemption is enabled. Issue a QUERY OPT command on your admin command line. If the option NOPREEMPT = (No), then your backups should be able to preempt lower priority processes if tape drive contention occurs (assuming you are backing up directly to tape for some backups or just some files, instead of a random disk pool or a sequential disk pool).

    Is reclamation called via an admin schedule? If so, you might be able to set priority. Default would be 5, it looks like. Lower priorities are more preemptable.
     
    Last edited: Dec 4, 2009
  17. Samuel

    Samuel ADSM.ORG Member

    Joined:
    Jul 9, 2008
    Messages:
    286
    Likes Received:
    1
    Dear All,

    I have more TSM Windows Server, and I need to reboot him one day per month for windows patchs. I finding a script to stop all TSM process and reboot the server.

    If you have an idea, don't hesitate to contact me.

    Thanks in advance.
     
  18. rulan

    rulan ADSM.ORG Member

    Joined:
    Jan 23, 2008
    Messages:
    20
    Likes Received:
    1
    C:
    cd \
    net stop "TSM Client Acceptor"
    net stop "TSM Journal Service"
    net stop "TSM Remote Client Agent"
    net stop "TSM Scheduler"
    net stop "TSM Client Scheduler"


    When completed with reboot

    net start "TSM Client Acceptor"
    net start "TSM Client Scheduler"
     
    Samuel likes this.
  19. Samuel

    Samuel ADSM.ORG Member

    Joined:
    Jul 9, 2008
    Messages:
    286
    Likes Received:
    1
    I'm not a specialist of Windows, but how do you do to put theses in the windows crontab ?
     
  20. rulan

    rulan ADSM.ORG Member

    Joined:
    Jan 23, 2008
    Messages:
    20
    Likes Received:
    1
    Put this in a notepad and save the file as a .cmd file. you can then set this in chron to run with the scheduler

    C:
    cd \
    net stop "TSM Client Acceptor"
    net stop "TSM Journal Service"
    net stop "TSM Remote Client Agent"
    net stop "TSM Scheduler"
    net stop "TSM Client Scheduler"
     
  21. Samuel

    Samuel ADSM.ORG Member

    Joined:
    Jul 9, 2008
    Messages:
    286
    Likes Received:
    1
    in unix it's 'crontab', in windows it's 'at'
     

Share This Page