cron任務執行oracle冷備提示:Invalid format of Export utility name

使用oracle數據庫用戶建立數據庫冷備腳本:

## 備份trade用戶數據
## 2016-02-05 11?00
/home/oracle/product/11gR2/bin/exp trade/trade@ORA11G file="/home/oracle/trade/`date +%Y%m%d%H%M%S`.dmp" log="/home/oracle/trade/`date +%Y%m%d%H%M%S`.log";
使用root用戶建立任務計劃
*/5 * * * * sh /home/oracle/trade/dmp.sh
到執行時間後未執行,mail提示:
From [email protected]  Thu Feb  4 14:40:01 2016
Return-Path: <[email protected]>
X-Original-To: oracle
Delivered-To: [email protected]
From: [email protected] (Cron Daemon)
To: [email protected]
Subject: Cron <oracle@hundsun> /home/oracle/product/11gR2/bin/exp trade/trade@ORA11G file="/home/oracle/trade/`date +
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/oracle>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracle>
X-Cron-Env: <USER=oracle>
Date: Thu,  4 Feb 2016 14:40:01 +0800 (CST)
Status: RO

/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
解決方法:

crontab執行時,是沒有在哪個帳戶下執行這樣的概念的,所以你想用的那個帳戶下的環境變量在腳本里用到的都需要在crontab裏重新設置一下,出現這樣的問題,在腳本里添加環境變量。然後export就可以了。

<pre name="code" class="plain">## 備份trade用戶數據
## 2016-02-05 11?00
## oracle 參數設置
ORACLE_BASE=/home/oracle/product
ORACLE_HOME=/home/oracle/product/11gR2
ORACLE_SID=ora11g
export ORACLE_BASE  ORACLE_HOME  ORACLE_SID
/home/oracle/product/11gR2/bin/exp trade/trade@ORA11G file="/home/oracle/trade/`date +%Y%m%d%H%M%S`.dmp" log="/home/oracle/trade/`date +%Y%m%d%H%M%S`.log";












發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章