crontab couldn't run through, help


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users crontab couldn't run through, help
# 1  
Old 02-15-2007
crontab couldn't run through, help

I have created two scripts to call SQL scripts to do some work. The scripts was successfully executed many times by manual. When I scheduled two scripts in crontab, I gave all necessary parameters. It could start, but couldn't run through. The log file didn't give enough error info. Anyone can help me to figure this out. What is the reason? Thanks.

1. crontab setting

0 4 * * 1-5 /app/xxxxx/xxxxx/scripts.ksh oracle_sid

2. error message in log file:

02/15/07 04:00:00: Database xxxprd.world is up and running.

02/15/07 04:00:00: Counting extraction records script started.

02/15/07 04:00:00: Error counting validation/xxxxxx_act.sql.
02/15/07 04:00:01: Exiting script.
# 2  
Old 02-15-2007
Usually when a script works manually but not from Cron it is because of the environment. Cron runs a basic bourne shell and won't have the path, aliases, environment variables, etc. that you will when you run it manually. I can't tell if that is your problem here but check it out. Make sure your script sets all needed variables and paths at the beginning of it.
# 3  
Old 02-15-2007
You are right. I do think it is environment setting. But I need to figure out which variable or path need to set.

Here are the env variables I used

#Initialize variables.
ORACLE_SID=$1
ORACLE_HOME=/oracle/product/9.2.0
WORK_DIR=`dirname $0`
MINUTES=0
DBDOWN=1
#FILECOUNT=0
#FILETRANSFERED=1


# Change to working directory.
cd $WORK_DIR

# Set environment variables.
export ORACLE_SID
export ORACLE_HOME
export PATH=$PATH:/oracle/product/9.2.0:/app/oracle/product/9.2.0/bin
export FILENAME

HERE IS THE EXECUTION PART

for filename in validation/cnt_*.sql
do
sqlplus -s > temp.log 2>&1 dbuser/passwd@$ORACLE_SID @$filename
if [ $? = 0 ]
then date +"%D %T: $filename successully counted." >> count.log
else date +"%D %T: Error counting $filename." >> count.log

The error message came from last line. Please advise the problems. Thanks.

Last edited by duke0001; 02-15-2007 at 03:18 PM..
# 4  
Old 02-23-2007
Use absolute path for "validation/cnt_*.sql" like /x/y/z/validation/cnt_*.sql then give a try. by default cron will try to find that in /validation/cnt_*.sql which is causing the error..
# 5  
Old 02-23-2007
gopidesaboyina:

Thanks so much. I do think you have pointed out the key point. It is not the env setting. It is the path. I have modified script to run manually success. I will come back to report the result that crontab run.
# 6  
Old 02-26-2007
gopidesaboyina:

Sorry. I tried to use full path for the cnt_*.sql. It failed with the same message. Then, I manually run shell script. It run very fast and successfully. So what is the different between crontab execution environment and the environment that I logged in and manually execute the shell script? This is very weird and unbelieveable. Please advise. Thanks.
# 7  
Old 02-26-2007
cron is running as root or other user id ? login with same id and try to run manually. let's c that works or not..can you paste the error again & if possible contents of sql u r running...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't get my crontab to run

I'm trying to get a crontab to run, every Friday at 11am and the problem is that it isn't running at all. 0 11 * * 6 /Users/martinb/Documents/SYSADMIN/Regular-Scripts/Info-And-Backups.sh Here's a link to a screenshot of my script (I've censored my email address). Screen Shot 2017 11 03... (3 Replies)
Discussion started by: $shell_Learner
3 Replies

2. UNIX for Dummies Questions & Answers

Scripts can be run manually but couldn't run with cronjobs

I am from MQ/MB technology. My requirement is to display the queue manger and broker status on daily basis. If I manually run the script, it works fine and displays output. But when I have scheduled the same using cronjobs it shows only the queue manger status and not the broker status. Can... (3 Replies)
Discussion started by: Anusha M
3 Replies

3. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

4. HP-UX

Crontab do not run on PM hours

Hi All I have a problem, I wonder if you can help me sort it out: I have the following entry in the cron: 00 1,13 * * * /home/report/opn_amt_gestores_credito.ksh > opn_amt_gestores_credito.log But the entry only runs at 01:07 I have stopped the cron deamon, and started, but it still... (39 Replies)
Discussion started by: fretagi
39 Replies

5. Shell Programming and Scripting

Different output when run from crontab

Hi, I have a script which checks to see if an app is running and will restart it if it is not. For some reason when I run it from the crontab it always says it is not running. The script is as follows: - #!/bin/sh # # The following script will look for the PID of SickBeard and output... (15 Replies)
Discussion started by: simpic
15 Replies

6. Shell Programming and Scripting

run script through crontab using ksh

hi i have a script called test.sh. the content is ls >> crontest.txt. if i run manually it's giving output.but if i scheduled in crontab it's not giving output. crontab entry: 02 * * * * /sms5/SMSHOME/eds_sh/test.sh >> /sms5/SMSHOME/eds_sh/testfile/logfile 2>&1 I am using ksh.is there... (2 Replies)
Discussion started by: muraliinfy04
2 Replies

7. Solaris

crontab to run every 20 second

Hi experts, I want to set the crontab for my script which will run every 20 seconds I think below could be the possible one- */3 * * * * /export/home/username/scripts/runing.sh As my system(SOLARIS 9) is live- i am confused to implement before make sure !!! I need... (4 Replies)
Discussion started by: thepurple
4 Replies

8. UNIX for Advanced & Expert Users

CRONTAB does not run since reboot

Hi, we reboot our Linux server yesterday and since then (specialy last night) no job from crontab has run. Any idea ? What should I look for to investigate? Many thanks. (5 Replies)
Discussion started by: big123456
5 Replies

9. HP-UX

Run crontab every 6 days

Hi all, I need to run a shell script every 6 days using crontab. I've been searching a bit and found the following syntax for this: * * */6 * * /apps/temp/maxx.sh > /apps/temp/maxx.log 2>&1 respectively * * 0/6 * * /apps/temp/maxx.sh > /apps/temp/maxx.log 2>& Unfortunately when trying to... (8 Replies)
Discussion started by: Endo
8 Replies

10. Shell Programming and Scripting

output from crontab run

Hi, I am trying to schedule a job in linux through the crontab command.My script actually does some text processing and echoes some output.My cron scheduler is working fine,but the output messages(echoes from script) is mailed to my mail account(in unix -/var/local/mail).Is it not possible... (0 Replies)
Discussion started by: DILEEP410
0 Replies
Login or Register to Ask a Question