RMAN backup script not running from cron
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 9 of 9

Thread: RMAN backup script not running from cron

Hybrid View

  1. #1
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    Oracle 8.0.6
    Compaq Tru64 4.0D

    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.

    Code:
    #backup_full_db.sh
    #   
    export ORABIN=/ora01/app/oracle/product/8.0.6/bin
    export PATH=.:/ora01/app/oracle/product/8.0.6/bin:/opt/bin:/bin:/usr/bin:/usr/ccs/bin:/usr/local/bin
    export ORACLE_BASE=/ora01/app/oracle
    export ORACLE_SID=fdbsp
    export LD_LIBRARY_PATH=/ora01/app/oracle/product/8.0.6/lib:/usr/lib
    export ORACLE_HOME=/ora01/app/oracle/product/8.0.6
    #
    /ora01/app/oracle/product/8.0.6/bin/rman target sys/password@fdbsp rcvcat rman/rman@catlg cmdfile /ora01/app/oracle/cron/backup_ful
    l_db.rman msglog /ora01/app/oracle/cron/output/backup_full_db.log
    Code:
    #backup_full_db.rman
    run {execute script backup_full_db_al_disk;}
    exit
    Any idea? Appreciate all help.

    Sanjay

  2. #2
    Join Date
    Apr 2002
    Location
    Germany.Laudenbach
    Posts
    448

    Wink

    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!





  3. #3
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    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



  4. #4
    Join Date
    Apr 2002
    Location
    Germany.Laudenbach
    Posts
    448
    Send me please the output of

    Code:
    crontab -l
    Orca

  5. #5
    Join Date
    Mar 2001
    Location
    Ireland/Dublin
    Posts
    684
    Try this
    Create crontab as ROOT and use:
    00 01 * * 0 su -l oracle --command="/home/oracle/script.sh"
    Best wishes!
    Dmitri

  6. #6
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    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.

    Sanjay

    [Edited by SANJAY_G on 07-12-2002 at 05:24 AM]

  7. #7
    Join Date
    Apr 2002
    Location
    Germany.Laudenbach
    Posts
    448
    Sorry no idea !
    crons looks good
    Orca

  8. #8
    Join Date
    Apr 2002
    Location
    Germany.Laudenbach
    Posts
    448
    Hi,

    Look at this

    http://www.geocities.com/webdbaquest...an_backup.html

    In the backup-shell-script the first line specs the Shell for example.

    Orca

  9. #9
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    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.

    Thanks all for the response.

    Sanjay

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width