-
environment setup inside cron job
I like to schedule a job to be run at 8:00pm every night, and I know very a little about cron
job, basically I just want to get the exp of the database every night. Please correct me if I
am wrong. I have the script as below:
export ORACLE_SID=TEST
exp system/manager file=/u02/backup/TEST/exp_TEST_full.dmp
log=/u02/backup/TEST/exp_TEST_full.log full=y direct=y
and this script is save as backup_TEST.sh and it located on:
/home/oracle/TEST/backup_TEST.sh
seem like I have problem with setting the environment in my script but I used the same command to set environment when I do stuffs on the server and it worked.
Any advise of what command I should type inside the script????
thanks
-
Give
#!usr/bin/ksh
ORACLE_SID=TEST
export ORACLE_SID
exp system/manager file=/u02/backup/$ORACLE_SID/exp_$ORACLE_SID_full.dmp
log=/u02/backup/$ORACLE_SID/exp_$ORACLE_SID_full.log full=y direct=
Try out the above.
-
set your Oracle Home as well
When a job runs through cron is does a su to oracle without picking up any of the the Oracle profile information so all environment variables must be set explicitly in the cron script
steve
I'm stmontgo and I approve of this message
-
stmongo and prince_jr,
per your advise below is my script:
#!usr/bin/ksh
ORACLE_SID=TEST
export ORACLE_SID
ORACLE_HOME=/home/oracle/product/9.2.0
export ORACLE_HOME
exp system/manager file=/u02/backup$ORACLE_SID/exp_$ORACLE_SID_full.dmp
log=/u02/backup/$ORACLE_SID/exp_$ORACLE_SID_full.log full=y direct=y
so I save this as backup_TEST.sh and I tried to run ./backup_TEST and I got the error:
[oracle@qhoudb03 mytest]$ ./backup_TEST
bash: ./backup_TEST: bad interpreter: No such file or directory
Please advise, what's wrong here
-
Originally posted by ashley75
#!usr/bin/ksh
should be
#!/bin/ksh
or whatever your ksh shell is located.
Code:
#!/bin/ksh
# setup the environment
export ORACLE_SID=TEST
export ORAENV_ASK=NO;
. oraenv
FILE_STUB=/u02/backup/$ORACLE_SID/exp_$ORACLE_SID_full
exp system/manager file=$FILE_STUB.dmp log=$FILE_STUB.log full=y direct=y
or, alternatively, you can setup your environment in your crontab:
10 0 * * * (/bin/ksh "export ORACLE_SID=TEST; export ORAENV_ASK=NO, . $HOME/.profile; $HOME/your_export_script_goes_here.ksh")
Last edited by marist89; 10-24-2003 at 04:04 PM.
Jeff Hunter
-
Also, you know if you don't know WHY export is a VERY poor method for a backup, use "Search".
Jeff Hunter
-
run as
./backup_test.sh
if that does not work just give
backup_test.sh
Give the full name if you are not running from current directy
/home/oracle/TEST/backup_test.sh
-
-
Jeff and Prince_jr,
I got my script working when I issue ./backup_TEST.sh and everything seems to work fine. Below is my script:
#!/bin/bash
# full backup TEST
ORACLE_SID=TEST
export ORACLE_SID
ORACLE_HOME=/home/oracle/product/9.2.0
export ORACLE_HOME
exp system/manager file=/u02/backup/$ORACLE_SID/exp_$ORACLE_SID_full.dmp log=/u02/backup/$ORACLE_SID/exp_$ORACLE_SID_full.log full=y direct=y
and this file is saved in :/home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh
but I seem to have problem when I schedule this job to be run at 8:00pm every night.
below is the message I got in the mail:
From: root@localhost.localdomain (Cron Daemon)
To: oracle@localhost.localdomain
Subject: Cron /home/oracle/scripts/backup/TEST/backup_TEST.sh
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
/bin/sh: /home/oracle/scripts/backup/TEST/backup_TEST.sh: No such file or directory
Jeff,
I know exp/imp is not a good backup method but this is what the client wants.
thanks
Last edited by ashley75; 10-27-2003 at 04:08 PM.
-
Your saving it as:
/home/oracle/DBA_STUFFS/backup_scripts/TEST/backup_TEST.sh
but executing:
/home/oracle/scripts/backup/TEST/backup_TEST.sh
Jim
Oracle Certified Professional
"Build your reputation by helping other people build theirs."
"Sarcasm may be the lowest form of wit but its still funny"
Click HERE to vist my website!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|