Solved

cron job wont run

Posted on 2013-02-04
8
699 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

738 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