Solved

cron job wont run

Posted on 2013-02-04
8
686 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
  • 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now