Solved

cron job wont run

Posted on 2013-02-04
8
700 Views
Last Modified: 2013-02-05
Guys

I'm trying to create a cron job but the task doesn't run or more importantly it seems to do something but not what I'm after

here is the scripts

cron job =

30 15 * * * ksh /home/oracle/scripts/recreate_IFSLEU24.ksh >> /home/oracle/scripts/recreate_IFSLEU24.log

recreate_IFSLEU24.ksh =

#!/bin/ksh
export ORACLE_SID=IFSLEU_STBY_01
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_2
sqlplus /nolog << EOF
CONN / as sysdba
shutdown immediate
startup nomount;
EXIT;
EOF
#  RMAN restore IFSLEU database onto IFSLEU24
rman target sys/toshiba@IFSLEU_live auxiliary / cmdfile=/home/oracle/scripts/recreate_ifsleu24.rcv
# put into no archive log mode and remove additional undo tbs
sqlplus /nolog << EOF
CONN / as sysdba
shutdown immediate
startup mount;
alter database noarchivelog;
alter database open;
drop tablespace undotbs3 including contents and datafiles;
drop tablespace undotbs2 including contents and datafiles;
shutdown immediate
startup mount;
alter database open read only;
EXIT;
EOF


the cron job seems to fire as if I delete the log file it creates the log file but nothing more happens.

I'm thinking I'm doing something daft or missing something

can anyone help

Regards

Darren
0
Comment
Question by:DarrenJackson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 38851482
I assume that "sqlplus" and "rman" are not tn the default PATH "/bin:/usr/bin... etc." (or the PATH set in crontab, if any)
0
 

Author Comment

by:DarrenJackson
ID: 38851550
the problem is that it doesn't seem to get to that point the log file remains empty at zero bytes
0
 

Author Comment

by:DarrenJackson
ID: 38851567
just to add if I copy the line and run it manually it all works OK
0
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 38851579
Yes,

because the job doesn't produce any ouput on stdout, only on stderr.
You're capturing just stdout, so no wonder that the log file is empty.

stderr should be mailed to the owner of the crontab (or the recipient configured in MAILTO).
Didn't you get any mail?

Best change the job like this

30 15 * * * ksh /home/oracle/scripts/recreate_IFSLEU24.ksh >> /home/oracle/scripts/recreate_IFSLEU24.log 2>&1

What does the logifle contain now?

Your job works from command line because you're in your own environment which certainly contains a PATH to sqlplus. cron's environment is different!
0
 

Author Comment

by:DarrenJackson
ID: 38851590
ahh ok let me try thanks
0
 

Author Comment

by:DarrenJackson
ID: 38851651
right im getting more helpful error now

/home/oracle/scripts/recreate_IFSLEU24.ksh[4]: sqlplus: not found [No such file or directory]
/home/oracle/scripts/recreate_IFSLEU24.ksh[11]: rman: not found [No such file or directory]
/home/oracle/scripts/recreate_IFSLEU24.ksh: line 13: sqlplus: not found


what do I need to do to fix this

Regards
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 38851885
Edit your script

 recreate_IFSLEU24.ksh

and either add the full paths to sqlplus and rman (should be $ORACLE_HOME/bin/sqlplus and $ORACLE_HOME/bin/rman) or add "export PATH=$ORACLE_HOME/bin:$PATH" right after "export ORACLE_HOME=..."
0
 

Author Closing Comment

by:DarrenJackson
ID: 38855032
Great thanks it now works
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question