3 Replies Latest reply: Nov 19, 2012 7:22 AM by Kazi RSS

    crontab is not running to export DMP

    Kazi
      Hi Gurus!

      I have created a shell script(schema_exp.sh) to export the DMP as below:

      exp hr/hr file=/home/samir/hr.DMP

      Then I edited the crontab as below

      $crontab -e

      */1 * * * * /home/samir/schema_exp.sh

      N.B. If I run the shell script(schema_exp.sh) from the terminal, the DMP is being exported. But from scheduler I am not getting DMP using this shell script. Please any help?

      Regards
      Mokarem
        • 1. Re: crontab is not running to export DMP
          Catch_22
          Cron does not go through any login profiles and therefore has no information other than the default path. For Oracle you need to explicitly define ORACLE_HOME, PATH, SID, etc. See the following example:

          <pre>
          #!/bin/sh
          #
          ORACLE_SID=test
          ORAENV_ASK=NO
          . oraenv -s
          #
          sqlplus -s /nolog <<-EOF
          set pages 0 feed off
          connect / as sysdba
          select status from v\$instance;
          exit
          EOF
          # END
          </pre>
          • 2. Re: crontab is not running to export DMP
            Veeresh.S
            in your shell script add

            export ORACLE_SID,ORACLE_HOME,PATH prior to exp command

            and then see if cronjob executes it

            also its better if you append *>>schema_exp.log* to the cronjob to save its output


            */1 * * * * /home/samir/schema_exp.sh >>schema_exp.log
            • 3. Re: crontab is not running to export DMP
              Kazi
              Thanks all helps. I required to set ORACLE_BASE also as below
              #Shell script to export DMP

              ORACLE_BASE=/usr/u01/app/oracle; export ORACLE_BASE
              ORACLE_SID=orcl; export ORACLE_SID
              ORACLE_HOME=/usr/u01/app/oracle/product/10.2.0/db_1 ; export ORACLE_HOME
              PATH=${ORACLE_HOME}/bin:${PATH} ; export PATH
              exp hr/hr file=/home/samir/hr.DMP log=/home/samir/hr.log

              It successfully exported the DMP. I added the option to create log file also in cronbtab. Everything has been done successfully.


              Thanks.