Ask the Expert

Unix script to create database export via crontab

Hi Brian. I need to find a Unix script that will run via crontab and create a full database export. The script I have attached runs OK via ./export.sh in a Unix shell (about two hours and is 22 GB in size), but when I run it via a crontab job, it takes 18 odd hours and is about three times the actual size. I would appreciate your help on this. The script is below:
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:. 
  ; export PATH
ORACLE_SID=ris ; export ORACLE_SID
ORACLE_BASE=/oracle/app/oracle   
  ; export ORACLE_BASE
ORACLE_HOME=/oracle/app/oracle/product/10.2.0/RIS 
  ; export ORACLE_HOME
ORACLE_OWNER=oracle     ; export ORACLE_OWNER
ORACLE_GROUP=dba  ; export ORACLE_GROUP 
PATH=$PATH:$ORACLE_HOME/bin   ; export PATH
CLASSPATH=$ORACLE_HOME/DBCreate/oradev/classes/orapts.jar:
  $ORACLE_HOME/jdbc/lib/classes12.zip:$CLASSPATH
  ; export CLASSPATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH 
  ; export LD_LIBRARY 
ORAENV_ASK=NO 
TNS_ADMIN=$ORACLE_HOME/network/admin
  ; export TNS_ADMIN
TERM=vt100 ; export TERM
NLS_LANG=AMERICAN_AMERICA.US7ASCII  
  ; export NLS_LANG exp USERID="username/password@SID" 
  FILE=/oracle/app/oracle/dump/test.DMP 
  LOG=/oracle/app/oracle/dump/test.LOG COMPRESS=Y DIRECT=Y 
ROWS=Y CONSISTENT=Y FULL=Y # END

    Requires Free Membership to View

The only thing that I would change is to move $ORACLE_HOME/bin as the first directory in your PATH.

Next, I would run the above script in its own shell, mimicking what crontab does. To do so, use the following:

sh -x scriptname

This will execute the script in its own environment, not yours. You will often see things not obvious to you when you run the script yourself.

This was first published in August 2006

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: