Solved

cron job wont run

Posted on 2013-02-04
8
691 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

919 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

16 Experts available now in Live!

Get 1:1 Help Now