crontab couldn't run through, help


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users crontab couldn't run through, help
# 8  
Old 02-27-2007
If in cron_allow file, user name is listed, this user can execute crontab. I, as a uers in that UNIX saver, have 3 other scripts to call a bounch of PL/SQL scripts to do the work. They all work perfectly. This script is also working perfectly when I login and manually execute. Only thing is that I schedule it in crontab, it will failed with these mesage:

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

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

02/27/07 04:00:00: Error counting
/app/xxxx/scripts/xxxx/validation/cnt_xxxx_act.sql.
02/27/07 04:00:00: Exiting script.

I have tried different ways such as running .profile to set up oracle environment, using full path to locate PL/SQL scripts. It is hard for me to understand why manually execution worked and crontab execution failed.

Here is the basic part of script:

#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 if [ $? = 0] condition, which means crontab couldn't get first comdition, then go to second comdition. IF if condition is wrong, how could I manually execute successfully. Please help. Thanks.
# 9  
Old 02-27-2007
This doesn't look like cron issue..may be sql is exiting. so the cron is catching that error...look for sql..if possible put spool on that sql..
# 10  
Old 02-27-2007
gopidesaboyina:

Actually, I think it is the problem that script look for env variables settings. programming in script is not wrong, cron didn't set up these env variables. So I added some command in crontab and tested. It seems work fine. I will monitor tonight. If it works again, I will come to report. Thanks for your help.

This is the report:

I created a env_profile in home directory and add piece of code in crontab. When crontab execute, it will go to that profile to find variables. Then shell script run successfully.

Last edited by duke0001; 02-28-2007 at 12:23 PM..
# 11  
Old 02-06-2008
Hammer & Screwdriver

hi duke,

i too have the same problem with crontab it is working manually. but if i schedule it at crontab it doesn't work . please tell me what is the piece of code written for env_profile.

thanks
vaddi
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