![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| gcd.sh script doesn't work... | kantze | Shell Programming and Scripting | 1 | 01-17-2008 05:46 PM |
| Modify Perl script to work with txt - Permissions script | joangopan | Shell Programming and Scripting | 1 | 09-12-2007 08:38 PM |
| My script does not work - could you pls help? | BearCheese | Shell Programming and Scripting | 1 | 06-29-2007 02:12 AM |
| Script doesn't work, but commands inside work | cheongww | UNIX for Dummies Questions & Answers | 2 | 11-14-2006 06:52 PM |
| sed script. How does it work? | billy5 | Shell Programming and Scripting | 2 | 09-02-2005 01:45 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Why does this script not work? Please help
I have created a Shell script to call 12 Oracle PL/SQL scripts to query some data and insert into a table. When I run shell scripts manually, it works very well. But when I schedule shell script in crontab, it will give the error message like this:
02/22/07 04:00:00: Database mydb.world is up and running. 02/22/07 04:00:00: Counting extraction records script started. 02/22/07 04:00:00: Error counting validation/PL_SQL_1.sql. 02/22/07 04:00:00: Exiting script. It seems that crontab started to execute shell script, when it went to call PL/SQL scripts, it failed. So I think that I may missed something in crontab settings. But I don't know what it is after I man crontab. I also post a part of my shell script for your information. Please help me to solve this problem. Many thanks in advance. Here is the code: # Started to insert records into xxxx_rowcount table. for filename in validation/cnt_xxxx_*.sql do sqlplus -s > temp.log 2>&1 db_stg/db_passwd@$ORACLE_SID @$filename if [ $? = 0 ] then date +"%D %T: $filename successully counted." >> row_count.log else date +"%D %T: Error counting $filename." >> row_count.log grep "ORA-" temp.log >> row_count.log date +"%D %T: Exiting script." >> row_count.log mail -s 'CAFMII Load: Unsuccessful. See log file for errors.' btmna@yahoo.com<row_count.log exit 1 fi done Highlighted part is in error message. It seems that script couldn't count $filename. Do I need to add filecount=xx in the script. Please advise. |
| Forum Sponsor | ||
|
|
|
|||
|
Yes, it is for setting the environment. You mentioned that you were able to run the script successfully manually with your login and the same script was failing from the crontab. so the most obvious reason could be the environment settings present in your .profile file( it is executed every time you login so the environment settings are set as soon as you login). whenever the script is invoked from cron it does not execute the .profile file so the environment settings are missing and leading to the script failure.
|
|
|||
|
Your explanation may be correct. But I have other 3 shell scripts to be executed under the same user. Two of them do the same job to call many PL/SQL scripts to do the work. One of them was created recently and is to call two PL/SQL to do the work. I scheduled 3 shell scripts in crontab without running .profile. The same environment and Solaris shell on these shell scripts. This is why I am confused. I think it may be the coding in shell scripts that can not go through the list of PL/SQL files. The error message is not clear for me to identify the reason on this. But I will try your method to run .profile to make envirnment ready. Then I will report the result. Thanks.
|
|||
| Google The UNIX and Linux Forums |