Thursday, June 24, 2010

crontab doesnt execute bash profile..

Crontab doesnt execute bash profile.....check below errors and then solution with examples......
I have created a bash script rakesh.sh
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#!bin/bash
export DATE=$(date +"%m_%d_%y_%H:%M:%S_%p")/u01/app/oracle/product/10.2.0/db_1/bin/exp rakesh/rakesh@rockdb file=/home/oracle/backups/rakesh$DATE.dmp log=/home/oracle/backups/rakesh$DATE.log statistics=none
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The script is runing perfectly fine from commandline. ./rakesk.sh
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[oracle@oraclelinux bin]$ crontab -e SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=oracle
HOME=/
*/5 * * * * sh /home/oracle/rakesh.sh
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The above crontab command is failed when we check the /var/spool/mail/oracle file, the log file says:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Invalid format of Export Utility name
verify that ORACLE_HOME is properly set
Export terminiated unsuccessfully
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Solution: CRON does not execute .bash_profile or .profile. We need to set environment variables in the script. I have modified the script as below, and now its working fine, runing every five minutes..
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#!/bin/bash
export ORACLE_SID=db
export PATH=$PATH:/usr/local/bin
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES
export DATE=$(date +"%m_%d_%y_%H:%M:%S_%p")/home/oracle/oracle/product/10.2.0/db_1/bin/exp rakesh/rakesh@rockdb file=/home/oracle/backups/test$DATE.dmp log=/home/oracle/backups/test$DATE.log statistics=none
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Now its working :) :)

Thursday, June 17, 2010

Automating Oracle DB startup in Linux

I am writing steps that will auto start Oracle Database along with linux OS startup.

1. connect with Oracle user and edit the "/etc/oratab" file setting flag to 'Y'. soni:/home/oracle/oracle/product/10.2.0/db_1:Y
2. connect wih root user- created empty file (/etc/init.d/dbora) and write:




















3. chmod 750 /etc/init.d/dbora
4. chkconfig --add dbora
5 check whether dbora is working or not.. as root issue /etc/init.d/dbora start
# /etc/init.d/dbora start
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
Processing Database instance "soni": log file /home/oracle/oracle/product/10.2.0/db_1/startup.log

We got any error in listner settings... This is due to a hard coded path in the dbstart script. To correct this, connect with Oracle user, edit the "$ORACLE_HOME/bin/dbstart" script and replace the following line (approximately line 78): ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle with ORACLE_HOME_LISTNER=$ORACLE_HOME and then check
# /etc/init.d/dbora start
Processing Database instance "soni": log file /home/oracle/oracle/product/10.2.0/db_1/startup.log
---------------
Congratz you are DONE :)

Sunday, June 13, 2010

Oracle Installation in Linux

After Linux Installation, I have installed Oracle10g 2 in Linux machine. I followed steps given at below link.
http://www.oracle.com/technology/pub/articles/smiley_10gdb_install.html
http://www.oracle.com/technetwork/articles/smiley-10gdb-install-092939.html
Check "Part II: Configuring Linux for Oracle"

Friday, June 11, 2010

Linux Installation

Installing Linux
>Boot from RHEL4 disc1
>press enter for graphical install
** Need at least 512MB RAM / 2.5GB Space **
>Manually partition your hard drive with Disk Druid
/tmp = 512MB ext3 fixed size
/boot = 128MB ext3 fixed size
Swap = 1024MB fixed size
/ = fill to maximum allowable size

Wednesday, June 9, 2010

Oracle Linux

These days, I am working on Linux OS, migrating Oracle10g database from Windows to Linux.
I have installed Oracle10g in Linux. I will post the steps of "Oracle10g installation in Linux", soon.