I am trying to RMAN backup job from cron.
The shell script I wrote works fine when run interactively but doesn't work when scheduled through cron. The log file, to which I am directing the output of the shell comes blank.
I suspect I am missing some environment variables but don't know which one? Below are my shell script and rman script.
#backup_full_db.rman
run {execute script backup_full_db_al_disk;}
exit
Any idea? Appreciate all help.
Sanjay
07-12-2002, 02:12 AM
Orca777
Hi;
Have you tried the script starting in background
Code:
cmd &
- When some errors occur cron writes a mail; have you checked this
- you manually recreate the environment, would it be possible to execute the profiles in your script
Code:
# Not forget the point-command ( exec in this shell )
. /etc/profile
. /u/...home/oracle/.profile # or .bash_profile
to get the whole environment
in cron you can explicit direct the stderr and stdout to disk
Code:
cmd > file.log 2> file.err
Hope it helps
Orca
PS.: i would appreciate to work under TRUE64!
07-12-2002, 04:20 AM
SANJAY_G
Hi Orca, thanks for the response..
- No mail generated. Checked it.
- tried running .profile in the script. It also doesn't work.
- i am explicitly dircting the cron output to a log file. That log file is generated but it is blank with size 0 bytes.
I tried running the shell script interactively under root and it works. It only doesn't work when put in cron.
Any other reason??
Sanjay
07-12-2002, 04:26 AM
Orca777
Send me please the output of
Code:
crontab -l
Orca
07-12-2002, 04:37 AM
kgb
Try this
Create crontab as ROOT and use:
00 01 * * 0 su -l oracle --command="/home/oracle/script.sh"
07-12-2002, 05:21 AM
SANJAY_G
excerpts from crontab for user oracle
Code:
# RMAN job to backup full database to disk everyday.
#
16 16 * * * /ora01/app/oracle/cron/backup_full_db.sh > /ora01/app/oracle/cron/output/backup_job.log
#
Hi kgb, ideally the job should work under user oracle. Though I didn't try under root.
In the backup-shell-script the first line specs the Shell for example.
Orca
07-15-2002, 02:31 AM
SANJAY_G
A ha!!
It works now. I have added the following line at the start of the shell script and it did the trick.
#!/bin/ksh
The environment variable defined in my script were not getting executed because they were defined in korn shell format and by default the cron uses some other shell.