Problem with running the "autorep" command via crontab

Hi,
The user "MadeInGermany" tried to help on the below post by saying "This has been asked before; see the links below.
Get your current LD_LIBRARY_PATH and redefine that in your ksh script!
"
Thanks for the help. but this did not help. And my post got locked. I can't reply on my previous post.
So, the following is the issue :
I have written a ksh script and I'ma using the following command in it:

autorep -j %abcd% | grep RU | grep BOX1

The script works fine when executed manualy on the command prompt. But does not work when scheduled in crontab. I could see the following in the crontab log:

/AutosysScript.ksh[12]: autorep: cannot execute

I then used the whole path of autorep which was /opt/CA/UnicenterAutoSysJM/autosys/bin/autorep instead of just autorep. And then I got the following error in the crontab log after running the script:

ld.so.1: autorep: fatal: libascmn.so: open failed: No such file or directory
/AutosysScript.ksh[13]: 16123 Killed

Can someone please advice how can I run the autorep command within a ksh script from crontab.

As adviced by the user "MadeInGermany", I added the following line in the beginning of my script, but no use :frowning:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/CA/UnicenterAutoSysJM/autosys/bin:/opt/CA/UnicenterAutoSysJM/autosys

Can some one please help !

Many thanks !

Try . /etc/profile at the top of the script, to load the usual profile you'd get on your system.

Thanks Corona,

I tried the following at the top of the script but they didn't resolve the issue:

. /etc/profile
 
LD_LIBRARY_PATH=`extendpath $LD_LIBRARY_PATH /opt/CA/UnicenterAutoSysJM/autosys/bin`
 
export LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/CA/UnicenterAutoSysJM/autosys/bin:/opt/CA/UnicenterAutoSysJM/autosys

Error in Crontab log:

 
ld.so.1: autorep: fatal: libascmn.so: open failed: No such file or directory
/home/clasp1/utilsGSD/Girish/AutosysRefreshCheck.ksh[32]: 27142 Killed

Is the problem due to 2 copies of the same file in 2 different locations in the library as follows:

$ cd /opt/CA/UnicenterAutoSysJM/autosys
$ find ./ -name libascmn.so
./lib_bak_Jul_04_08:44/libascmn.so
./lib/libascmn.so
$ 

Thanks

Have you looked at what's in your ~/.profile yet?

Doing 'man crontab' yields:

       Only the first line (up to a `%' or end of line) of the	command  field        is executed by the shell. Other lines are made available to the command        as standard input. Any blank line or line beginning with  a  `#'  is  a        comment and is ignored.

If you're using the 'autorep' as quoted above in cron by itself (not as part of a wrapper script), you'll need to escape the embedded '%':

autorep -j \%abcd\% | grep RU | grep BOX1

If you're using a wrapper script, check your environmental settings and check this FAQ

1 Like

Thanks Corona / Vgresh,

But before seeing your post, I converted the script to CSH and it runs fine in crontab.

Thanks very much.