3 Replies Latest reply on Nov 19, 2012 1:22 PM by Kazi

    crontab is not running to export DMP

      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?

        • 1. Re: crontab is not running to export DMP
          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:

          . oraenv -s
          sqlplus -s /nolog <<-EOF
          set pages 0 feed off
          connect / as sysdba
          select status from v\$instance;
          # END
          1 person found this helpful
          • 2. Re: crontab is not running to export DMP
            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
            1 person found this helpful
            • 3. Re: crontab is not running to export DMP
              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.