The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can we edit crontab using a shell script rudrarajumk Shell Programming and Scripting 6 06-16-2009 08:45 AM
crontab entry modification using shell script munishdh Shell Programming and Scripting 4 07-01-2007 05:47 AM
How to remove line from crontab in shell script? nir_s Shell Programming and Scripting 2 11-03-2005 01:19 PM
Shell script doesn't get executed using crontab radhika Shell Programming and Scripting 11 06-09-2005 04:28 PM
root executes a script as another user tads98 Shell Programming and Scripting 1 05-17-2005 08:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-06-2005
radhika radhika is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 51
crontab and shell script that executes a sql.

Problem:
I have a crontab and when it kicks off, xxx.sh shell script is called. Which has a nohup sqlplus session call. Problem is sql does not get executed and a text file is not getting created. Only a empty log file is getting created. Are there any constraints for crontab to open a sql plus session? Why is the sql not spooling the data? If I execute this shell script on command line every thing works nicely.

I have a crontab that is calling a shell script:
28 14 * * 1-5 $HOME/xxx.sh >> $HOME/xxx.log

code in xxx.sh:
nohup sqlplus userid/password@host @${SCRIPTSD}/xxx.sql ${OUTPUTD}/outfile.txt $datamonth > ${SCRIPTSD}/xxx.log &

wait
exit 0

Only the xxx.log file is getting created. No data file is getting created!
Does anybody know what's the problem.

ThankYou,
Radhika.
  #2 (permalink)  
Old 06-06-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,206
Radhika, please read the FAQs and search before posting.

This is most likely because the environment is not set up to run the commands in your script from cron.

the user in this thread had the same problem. This tread was a direct link from the cron and crontab faq.
  #3 (permalink)  
Old 06-06-2005
r2007's Avatar
r2007 r2007 is offline
Registered User
  
 

Join Date: Jun 2005
Location: China
Posts: 73
2 suggestions:

1. redirect stderr to a file, to see what happens.
28 14 * * 1-5 $HOME/xxx.sh >> $HOME/xxx.log 2>>error.log

2. add relative environments for sqlplus in xxx.sh.
  #4 (permalink)  
Old 06-06-2005
radhika radhika is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 51
I am sourcing the file by putting the following command in the shell script:

. .profile

It still doesn't work. I am going to try the trace on and see what happens.

Thanks,
Radhika.
  #5 (permalink)  
Old 06-06-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,206
Quote:
Originally Posted by radhika
I am sourcing the file by putting the following command in the shell script:

. .profile

It still doesn't work. I am going to try the trace on and see what happens.

Thanks,
Radhika.
What shell is the the users login shell? It it is a csh or tcsh user then .profile will not be the one used to set up the user environment.
  #6 (permalink)  
Old 06-06-2005
radhika radhika is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 51
It is kshell.
  #7 (permalink)  
Old 06-06-2005
radhika radhika is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 51
It worked! I was sourcing the wrong profile file- the one with application variables and not the generic one with environment set up information. I guess it IS! time to call it a day.

ThankYou! all for your suggestions.
Radhika.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0