ADSM-L

Re: [ADSM-L] schedulde command with date suffixed log file

2014-04-01 05:18:03
Subject: Re: [ADSM-L] schedulde command with date suffixed log file
From: PAC Brion Arnaud <Arnaud.Brion AT PANALPINA DOT COM>
To: ADSM-L AT VM.MARIST DOT EDU
Date: Tue, 1 Apr 2014 11:16:12 +0200
Dave,

Thanks a lot for both explanations and example.

Using these, I've finally been able to get the command accepted by the server :

tsm: TSM1_XXXXXX>def sched aix test_sched  act=command  objects="'/tmp/test.sh 
>/tmp/test.log.`date +%d.%m.%Y` 2>&1'" durunits=minutes duration=10 
startt=10:30 peru=o priority=1
ANR2500I Schedule TEST_SCHED defined in policy domain AIX.

Unfortunately, the execution failed, due to single quotes surrounding the 
command :

04/01/14   10:30:44
Executing Operating System command or script:
   '/tmp/test.sh >/tmp/test.log.`date +%d.%m.%Y` 2>&1'
04/01/14   10:30:44 Finished command.  Return code is: 127
04/01/14   10:30:44 ANS1909E The scheduled command failed.
04/01/14   10:30:44 ANS1512E Scheduled event 'TEST_SCHED' failed.  Return code 
= 127.

I then tried my chance with a macro :

DEFINE SCHEDULE AIX TEST_SCHED                                             \
       ACTION=COMMAND                                                      \
       SUBACTION=''                                                        \
       OPTIONS=""                                                          \
       OBJECTS="/tmp/test.sh >/tmp/test.log.`date '+%d.%m.%Y'` 2>&1"       \
       PRIORITY=5                                                          \
       STARTDATE=today                                                     \
       STARTTIME=now+00:10                                                 \
       DURATION=1                                                          \
       DURUNITS=HOURS                                                      \
       PERUNITS=ONETIME                                                    \
       DAYOFWEEK=ANY                                                       \
       EXPIRATION=NEVER

This time it ran successfully :

Scheduled Start      Actual Start         Schedule Name Node Name     Status
-------------------- -------------------- ------------- ------------- ---------
04/01/14   11:09:01  04/01/14   11:09:04  TEST_SCHED    XXXXXXXX      Completed


Cheers.

Arnaud


-----Original Message-----
From: ADSM: Dist Stor Manager [mailto:ADSM-L AT VM.MARIST DOT EDU] On Behalf Of 
David Bronder
Sent: Monday, March 31, 2014 6:16 PM
To: ADSM-L AT VM.MARIST DOT EDU
Subject: Re: schedulde command with date suffixed log file

On 03/31/2014 09:27 AM, PAC Brion Arnaud wrote:
>
> A quick one: does anyone have the proper syntax to define a client schedule 
> (using admin command line, or macro) that would execute a command having some 
> date-suffixed log file, like :
>
> def sched aix test_sched  act=command  objects="/tmp/test.sh 
> >/tmp/test.log.`date '+%d.%m.%Y'` 2>&1" durunits=minutes duration=10 
> startt=now peru=o priority=1
>
> TSM server is 6.3.3.1 and runs under AIX .
>
> I already have tried various combinations of single and double quotes without 
> success  ...

First, if you included the objects string verbatim, you have an extra space
between "test.log." and the date subshell.

Generally, the most reliable method would be to wrap the entire client
command in a simple shell script on the client.  Then the TSM client just
executes the wrapper and the wrapper handles the shell metacharacters
(redirection, subshell date, etc.).

If that's not an option, you could try something like this:

  ... objects="/usr/bin/sh -c '/tmp/test.sh >/tmp/test.log.`date +%d.%m.%Y`
2>&1'" ...

The extra quotes around the argument to date aren't usually necessary unless
something else is evaluating the % characters before date gets them.  With
POSIX-compliant shells, including modern sh/ksh, you can also use $(...)
instead of `...` for subshells (may not make a difference here, but can be a
useful tool in the shell arsenal).

=Dave

--
Hello World.                                David Bronder - Systems Architect
Segmentation Fault                                      ITS-EI, Univ. of Iowa
Core dumped, disk trashed, quota filled, soda warm.   david-bronder AT uiowa 
DOT edu<mailto:david-bronder AT uiowa DOT edu>

<Prev in Thread] Current Thread [Next in Thread>