Solved

Executing PRO*C binary from crontab

Posted on 1998-10-14
9
325 Views
Last Modified: 2013-12-26
We have a Pro*C executable which we are trying to execute from the cron. But the process execution goes into an infinite loop. The crontab entry is as below :

05 12 * * 0-6 /oracle/autopo

The Pro*C binary should be run at 12:05 a.m., do the needful and exit. But instead no updations take place and the process keeps on running forever.
0
Comment
Question by:vaid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 

Author Comment

by:vaid
ID: 1293694
Pro*C is an Oracle 7.1 Product.
0
 
LVL 2

Expert Comment

by:seedy
ID: 1293695
Typical Pro*C executables need a lot of environment variables (like, ORACLE_HOME, ORACLE_SID, etc) need to be set to function correctly.  Normally they are set from your shell start up files like .profile and so the program will work fine.

But when you run any executable from the cron, they are run directly - no shell is run.  This may be the problem. Create a shell script as below:

export ORACLE_HOME=...
export ORACLE_SID=...
.
/oracle/autopo
.

Then call the script from the crontab as

05 12 * * 0-6 /oracle/autopo.sh

(I am assuming that the shell script is named as autopo.sh)
0
 
LVL 2

Expert Comment

by:seedy
ID: 1293696
Oops!  You may have to have the cron entry as

05 12 * * 0-6 /usr/bin/ksh /oracle/autopo.sh

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:seedy
ID: 1293697
Again, I spoke little too soon - without verifying.  Cron runs all commands using /usr/bin/sh. with a limited environment variables set.  
0
 
LVL 2

Expert Comment

by:kellyjj
ID: 1293698
Seedy  

I think that the using a shell script is still the best way to go.  that way he can make sure all the env he needs is properly shet.  
0
 
LVL 1

Expert Comment

by:vulkanr
ID: 1293699
i agree with seedy and kellyjj,
probably the user's default shell is not "sh" but "csh" or
"tcsh" and therefore, when it logins , the .cshrc runs.

however, cron runs with "sh" so that .cshrc will not be run.
you should either make a script to run the program or change
the program so it will "putenv" the needed variable as it starts.
0
 

Accepted Solution

by:
jbarsug earned 50 total points
ID: 1293700
Try this shell:

# shell program /export/home/CRONUSER/autopo.sh
set -ua

# path per 'env'

PATH=/usr/bin::/opt/contrib/bin:/opt/local/bin:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/ucb:/usr/bin/nsr/:.:/opt/oracle/product/7.3.4/bin

# go to cron user home
cd /export/home/"YOURUSERNAME"

# define other env ; I changed umask to overide system defaults

umask 000
PATH=$PATH:.

# insert your SID and oracle stuff
ORACLE_SID=XXXXX
ORAENV_ASK=NO
 oraenv
SQLPATH=/opt/local/sql
LD_LIBRARY_PATH=/usr/dt/lib:/usr/openwin/lib

# run autopo executable
cd /oracle
 autopo

------------------- Crontab

05 12 * * 0-6 ${HOME}/autopo.sh 1>/dev/null 2>/dev/null

0
 

Expert Comment

by:jbarsug
ID: 1293701
a few dots and spaces didn't cut and paste  like dot space oraenv
and dot space autopo but you get the idea
0
 

Author Comment

by:vaid
ID: 1293702
I have seen jbarsug's answer in my mail, but have not been able to try it out. But, I have been able to find a solution to my problem after great R&D. The solution is :-
             1) I am executing the Pro*C binary from within a shell
             2) I have exported the required Oracle environment
                variables within the shell.
             3) After export I am executing the binary using the
                 following command :-
                 su oracle "-c /oracle/autopo -9 -u"
                 exit
Through the above command the execution from crontab is perfect.
Thanks,
Vaid
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how do i create updater to My Activex application? 3 102
dog bark java program 15 121
no14 challenge 14 74
Adjust the codes 3 37
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question