All Forums Database
Jaguar 25 posts Joined 05/06
25 Jan 2007
Running bteq scripts through crontab

Hi All,I want to execute a shell script '' that contains --->*********bteq < /a123b/scripts/abc.btq >> /a123b/scripts/hello1.log 2 >> /a123b/scripts/hello1.log*********abc.btq is a bteq file containing some teradata bteq statements.The problem here is that this shell script runs absolutely fine if i execute it manually proving the fact that abc.btq is correct . The output is a log file containing the statement 'successful' But when i inserted the same shell script in crontab(a scheduler in unix) to execute it at a specific time everyday, it doesn't run. My crontab entry looks like this:* * * * * /a123b/scripts/ >> /a123b/scripts/hello1.log 2 >> /a123b/scripts/hello1.logHence the result is a log file of size 0 bytes. This brings me to the conclusion that the crontab can never execute a bteq script?.Can anybody help me out with this problem as to how to execute a bteq file using crontab

rkeith01 4 posts Joined 10/05
31 Jan 2007

Hello,Crontab is essentially, what I call "dumb", meaning that it does not automatically source in your profile.In your crontab entry you can insert the following before your existing crontab enter: "/your user home path/.profile;"So your crontab entry would look like:* * * * * /your user home path/.profile; /a123b/scripts/ >> /a123b/scripts/hello1.log 2 >> /a123b/scripts/hello1.logor you can do this atop each of your shell (ksh/sh) scripts.Also for crontab, or any other scheduling software that I've used, it's better to fully qualify your paths to all commands within all scripts.BoB

joedsilva 505 posts Joined 07/05
12 Feb 2007

To add a bit, you may want to use the . (dot) operator as well.* * * * * . $HOME/.profile; /a123b/scripts/ >> /a123b/scripts/hello1.log 2>&1

Luckyhansh 30 posts Joined 08/06
13 Feb 2007

su - username -c "/a123b/scripts/ >> /a123b/scripts/hello1.log 2>&1 "As crontab is for system level, use user-root's environment :-) Hope may be useful .Years ago when i elt data ,met with the same questions :-)you should also learn more about OS

abhird338 2 posts Joined 12/15
15 Dec 2015

I am running bteq through shell script. When I ran shell script manually it worked as expected.
when I tried of running same script through crontab, script is running but bteq not executing at all.
Where am I making mistake?
Anyone could help me out here?
crontab entry:
49 15 * * 1 /usr/bin/sh /home/support/DBQLogs/  >> /home/support/DBQLogs/DBQLogexp_del_log.txt 2>&1

date=$(date +"%d-%m-%y")

time1=$(date +"%T")


echo "================================================="

echo -e "\n\nbteq going to execute..Please wait...."

echo "================================================="


/opt/teradata/client/15.10/bin/bteq << EOF > DBQLog.txt









Fred 1096 posts Joined 08/04
16 Dec 2015

Did you not read the posts above? When cron runs your script, it does not source your user profile. Some options are given above, or Google search for cron profile environment to see some other ideas.

abhird338 2 posts Joined 12/15
16 Dec 2015

Thanks fred ..
your suggestion to search on google gave me some clear idea about cron environment.
And above options helped me lot..

You must sign in to leave a comment.