This content has been marked as final. Show 4 replies
Don't assume your .profile is applied when cron launches monitor.sh; it may not have a path to sqlplus. You can call a .profile from the cron command, but I find it easier to maintain if I put everything I need for the environment in monitor.sh.
If you add 2>&1 to the end of the crontab entry your errors will also be redirected to date.log and you may have another clue what is failing.
784786 wrote:As others mentioned but left incomplete ... when a script is started by cron, it DOES NOT invoke the user's .profile (or .bash_profile, as the case may be). It is the responsibility of the script itself to set ALL of the environment variables it needs. At the top of that list will be PATH, ORACLE_BASE, ORACLE_HOME, ORACLE_SID.
Could you please help me out..It is really messing me for no fault of mine i believe.
I am trying to schedule a job using crontab, It runs but looks like it either doesn't access the monitor.sql or it fails to produce output as you could see out is 0, but when i run the shell script directly it produces output perefectly.
Here is my script:
oracle-PPOST@pebsdbf01 /home/oracle # crontab -l
23 14 * * * /u01/app/oracle/product/10.2.0/admin/monitor.sh > /u01/app/oracle/product/10.2.0/admin/date.log
-rwxr-x--- 1 oracle oinstall 75 Nov 16 13:58 monitor.sql
-rwxr-x--- 1 oracle oinstall 62 Nov 16 14:19 monitor.sh
set time on
select sysdate from dual;
sqlplus "apps/appsdcs" @/u01/app/oracle/product/10.2.0/admin/monitor.sql
Here is an output:
-rw-r--r-- 1 oracle oinstall 0 Nov 16 14:23 date.log