vaid
asked on
Executing PRO*C binary from crontab
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.
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.
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)
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)
Oops! You may have to have the cron entry as
05 12 * * 0-6 /usr/bin/ksh /oracle/autopo.sh
05 12 * * 0-6 /usr/bin/ksh /oracle/autopo.sh
Again, I spoke little too soon - without verifying. Cron runs all commands using /usr/bin/sh. with a limited environment variables set.
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.
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.
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
a few dots and spaces didn't cut and paste like dot space oraenv
and dot space autopo but you get the idea
and dot space autopo but you get the idea
ASKER
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
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
ASKER