2
0:root@SERVER:/SERVER/fs_111 # dsmc q schedule
IBM Tivoli Storage Manager
Command Line Backup-Archive Client Interface
  Client Version 6, Release 4, Level 0.1  
  Client date/time: 03/09/2014 15:08:27
(c) Copyright by IBM Corporation and other(s) 1990, 2012. All Rights Reserved.

Node Name: SERVER_111
Session established with server TSM03: AIX-RS/6000
  Server Version 5, Release 5, Level 5.2
  Server date/time: 03/09/2014 15:08:27  Last access: 03/09/2014 15:02:58

    Schedule Name: foo
      Description: 
   Schedule Style: Classic
       Action: Incremental
      Options:  
      Objects:  
     Priority: 4
   Next Execution: 2 Hours and 7 Minutes
     Duration: 2 Hour 
       Period: 2 Day  
      Day of Week: Any
        Month: 
     Day of Month: 
    Week of Month: 
       Expire: Never

0:root@SERVER:/SERVER/fs_111 # 

From the output of the "dsmc q schedule" I can see that the next backup for this nodeid will be in "2 Hours and 7 Minutes". I can also see the "Server date/time".

My question: How can I get the next schedule time? It would be the server time plus next execution time. So in this example: "03/09/2014 17:15:27"

1 Answer 1

0

Here's a rough way to do what you want. It makes a few assumptions about the nature of the output but should provide you with a template for how you can expand a more exact solution to your problem.

Example

For this demo I'm taking the output you provided and putting it into a text file so I can "simulate" the TSM command running. That file I'm calling tsm_output.txt.

The following code will parse out the next execution time:

$ cat tsm_output.txt  | grep 'Next Exec' | awk '{print $3, $6}'
2 7

The first assumption my solution makes is that the nature of this output will be such that it's always Hours & Minutes. Building off of this we can then expand the hours & minutes so that they're seconds.

$ cat tsm_output.txt | grep 'Next Exec' | awk '{print $3"*60*60+"$6"*60"}' 
2*60*60+7*60

We can then pipe that output to a command line calculator tool called bc:

$ cat tsm_output.txt | grep 'Next Exec' | awk '{print $3"*60*60+"$6"*60"}' | bc
7620

So with the number of seconds, we can enlist the help of the date command to calculate the time from NOW + those seconds:

$ date -d "$(cat tsm_output.txt | grep 'Next Exec' | \
    awk '{print $3"*60*60+"$6"*60"}' | bc) seconds"
Wed Mar 12 06:22:42 EDT 2014

This tells date to display the time + the seconds of offset. This is of the form date -d "X seconds".

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.