Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cron job wont run

Posted on 2013-02-04
8
Medium Priority
?
704 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
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.:
Suggested Courses

704 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