shell script works form command line but not form crontab
i am learning linux and shell scripting , i install 9.2.0.1.0 oracle database on my linux 8.5, what i want to automate my oracle database export by crontab daily at night time e.g (4:15 am). i wrote a simple shell shell script (as an oracle user )exp.sh as below and save the script in
/home/oracle/shellprog/ directory.
#/bin/sh
# exporting user schema
ORACLE_HOME=/u02/app/oracle/product/9.2.0.1.0
dt=`date +%Y%m%d`
${ORACLE_HOME}/bin/exp system/oracle owner=scott file=/home/oracle/shellprog/scottexp.$dt
when i execute the exp.sh script form command line its works fine
[oracle@saif oracle]$ . exp.sh
login in as an oracle user a write the following crontab file
15 4 * * * /home/oracle/shellprog/exp.sh
problem is
shell script run form the command lines but not from the crontab via login as an oracle user
i also gave execute permision to exp.sh script
i try several thing to sort this out but did't work i try these things
1- hard code the $ORACLE_HOME in the script
2-include the directory path of the shell script in the .profile of oracle user
3- include the /home/oracle/shellprog path in the /etc/crontab file
4- copy the exp.sh (as a root) script in the /etc/cron.daily and and set the /etc/crontab as a root user like this
my /etc/crontab file is as following
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/home/oracle/shellprog:/u02/app/oracle/product/9.2.0.1.0/bin:/home/oracle
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
20 13 * * * oracle /home/oracle/shellprog/login.sh run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
i also change the user oracle to root in the /etc/crontab file but same result
all those steps results in negative , any one have solution
thanks in advance
saifee
|