Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems running a shell script from a cronjob.

Status
Not open for further replies.

aidanmoro

Programmer
Mar 7, 2006
3
0
0
IE
I'm trying to run a shell script from a cronjob

One of the lines of the script is

sqlplus apple/apple@DB @/opt/gtx/common/reconreport/run_report_detail > /dev/null

where run_report_detail is somthing like

spool report
select * from table_a
spool off;
exit;

however the report file is not being created when I run the shell script from a cronjob but is when I run it from the commamnd line. Has anyone ever come across an issue using spool as part of a cronjob?

thanks
 
This is asked in one or other of the Unix forums (fora?) every two weeks or so.

Answer always is:
A cron job does not go through your .profile (or whatever it is called in your shell),
and so some environment variables like $PATH or $ORACLE_SID are not set properly.

For more info I suggest doing a search at tek-tips.

hope this helps
 
You should change the /dev/null to a log file. That would have shown you the ENV errors.

The way I get around it is by adding:

00 * * * * su - oracle -c "xxxxx" > LOGFILE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top