CRON and exporting Oracle db

Issues related to software problems
Post Reply
troophel
Posts: 3
Joined: 2009/05/07 11:15:33
Location: where do children come?

CRON and exporting Oracle db

Post by troophel » 2009/05/07 11:24:09

Hi,

i want to simply export my Oracle db with cron using a command:

exp user/user file=ks.dmp

It works in at and launched from terminal but not in cron. It threw a mistake:

/bin/bash: exp: command not found

I made a symlink in /usr/bin to program exp placed in my oracle/bin folder and currently it throws:

Message 206 not found; No message file for product=RDBMS, facility=EXP: Release 10.2.0.1.0 - Production on Thu May 7 13:12:01 2009

Copyright (c) 1982, 2005, Oracl

Invalid format of Export utility name

Verify that ORACLE_HOME is properly set

Export terminated unsuccessfully

EXP-00000: Message 0 not found; No message file for product=RDBMS, facility=EXP

Do you have any idea what to do?

User avatar
AlanBartlett
Forum Moderator
Posts: 9323
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

CRON and exporting Oracle db

Post by AlanBartlett » 2009/05/07 14:41:48

When a [i]cron job[/i] executes it has the absolute minimum environment defined to allow it to run.

If you create a script file that defines / exports the environment variables required and calls [b]exp[/b] by it's full path name and then have [b]cron[/b] execute your script, the issue should be resolved.

The file [i]my_cron_task[/i] (with mode 755) should contain lines something like this --

[code]
[b]#!/bin/sh

export ORACLE_HOME=[/b][i]whatever[/i]
[b]export[/b] [i]other_environment_variable[/i][b]=[/b][i]whatever_the_second[/i]

[i]/full/path/name/to/[/i][b]exp user/user file=ks.dmp[/b]
[/code]

troophel
Posts: 3
Joined: 2009/05/07 11:15:33
Location: where do children come?

Re: CRON and exporting Oracle db

Post by troophel » 2009/05/17 21:59:41

Hi, i am really thankful for you help. I'm now ok with the exp problem. However, there has occured another one. Cron doesn't recognize the rm command. Cron is supposed to run this script:

[quote]#!/bin/bash
export ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_4
export PATH=/home/oracle/oracle/product/10.2.0/db_4/bin:/usr/bin:/usr/sbin
export ORACLE_SID=MILOW2
cd /home/oracle/Scripts
exp parfile=full.txt
cd /media/hdc1/DbBackups
split -b1900m ks_ora.dmp ks_ora
[b]rm ks_ora.dmp[/b]
zip -mo BackupMonday.zip ks_ora*[/quote]

I have no idea how to deal with it... Any guess?

User avatar
AlanBartlett
Forum Moderator
Posts: 9323
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: CRON and exporting Oracle db

Post by AlanBartlett » 2009/05/17 23:55:43

[quote]Any guess?[/quote]
Sorry, I'm right out of guesses at the moment . . . How about the answer? ;-)

The [b]rm[/b] command resides in the [b]/bin[/b] directory.

So either specify the full path to the [i]rm[/i] command --

[code]
. . .
split -b1900m ks_ora.dmp ks_ora
[b]/bin/rm[/b] ks_ora.dmp
zip -mo BackupMonday.zip ks_ora*
[/code]
or add the [i]/bin[/i] directory to the environment's PATH --

[code]
. . .
export PATH=/home/oracle/oracle/product/10.2.0/db_4/bin:/usr/bin:/usr/sbin[b]:/bin[/b]
. . .
[/code]

troophel
Posts: 3
Joined: 2009/05/07 11:15:33
Location: where do children come?

Re: CRON and exporting Oracle db

Post by troophel » 2009/05/19 11:23:26

Brilliant! I thought that the problem is in the enviroment variables :) Me grateful ;)

User avatar
AlanBartlett
Forum Moderator
Posts: 9323
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: CRON and exporting Oracle db

Post by AlanBartlett » 2009/05/19 15:02:16

[quote]Brilliant! I thought that the problem is in the enviroment variables :) Me grateful ;)[/quote]
You're welcome. :-D

Post Reply

Return to “CentOS 4 - Software Support”