Results 1 to 7 of 7
I am using cron( in RHEL 5 machine) to schedule the automatic backup of database.
I created a user cronjob through crontab -e for oracle user which is shown inside ...
- 04-27-2009 #1Just Joined!
- Join Date
- Apr 2009
- Posts
- 3
Cron job problem
I am using cron( in RHEL 5 machine) to schedule the automatic backup of database.
I created a user cronjob through crontab -e for oracle user which is shown inside /var/spool/cron/ with oracle name. the content of cronjob is given below
--------------------------------------------
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
#HOME=/home/oracle/
01 20 * * * * /data1/bkp.sh > /tmp/orasql.txt 2>&1
--------------------------------------------
The problem is instead of running this job through oracle user system is running the cron through root user which is not getting the sqlplus command inside the script.
Now how to change the default user.
The content of bkp.sh ---
---------------------------------------------
sqlplus -S '/ as sysdba' <<-ENDSQL
set pages 80
set feedback off
set head off
spool /data1/sysdata/files2backup.txt
select name from v\$datafile;
select name from v\$controlfile;
select member from v\$logfile;
select name from v\$tempfile;
spool off
exit
ENDSQL
------------------------------------------
Early reply will be awaited.
Thanks.
- 04-27-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Read your cron man pages. I notice that you have 6 date/time fields defined. There should only be five, so the last * might be confusing cron.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-28-2009 #3Just Joined!
- Join Date
- Apr 2009
- Posts
- 3
Sorry by mistake i have given this here in post only in cron there is 5 fields only
. but that is not an issue the thing is that when i created the cron for oracle user why it is running with root user. this is the reason it is not able to run sqlplus command.
Is there any way to find the reason?
- 04-28-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
It runs with the user id in the cron script. Look at /var/spool/cron/oracle and see who the owner for that file - ls -l /var/spool/cron/oracle should return a string something like this: -rw------- 1 oracle root 70 Apr 28 08:54 /var/spool/cron/oracle
If it shows root as the owner, then possibly the crontab program has been setuid root. That would be the next thing to look at in this case.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-29-2009 #5Just Joined!
- Join Date
- Apr 2009
- Posts
- 3
ys. this also i have checked the owner is oracle only.
- 04-29-2009 #6
- 05-04-2009 #7Just Joined!
- Join Date
- Jun 2007
- Posts
- 80
Login as "su" and then schedule your tasks .


Reply With Quote
