LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-12-2011, 07:30 AM   #1
daveant
LQ Newbie
 
Registered: Dec 2011
Posts: 9

Rep: Reputation: Disabled
cron job


All,

I am Oracle DBA I had created a cron for exporting the dmp files of our DB
The methodoly i followed was

Create a shell script

#!/bin/bash
#Script to Perform Datapump Export Daily
############################################################################
#DATE AUTHOR CHANGE
#--------- ----------------------- -------------------
#10-DEC-2011 Dave New Script Created
############################################################################
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_SID=test
export PATH=$PATH:$ORACLE_HOME/bin
expdt=`date +%d-%m-%Y-%H-%M`
expdp system/sys@test schemas=TEST dumpfile=TEST_$expdt.DMP directory=MY_DIR logfile=TEST_$expdt.log consistent=y
expdp system/sys@test schemas=TEST1 dumpfile=TEST1_$expdt.DMP directory=MY_DIR logfile=TEST_$expdt.log consistent=y
mv /home/oracle/ordump/TEST*.log /home/oracle/ordump/logs

Scheduled at cron

* 3 * * * /home/oracle/scripts/exp.sh 2>&1 /home/oracle/ordump/logs/CS_cron.log

Cron is working fine but the log output of cron is directed into default i,e in /var/mail/oracle although i had given the path " /home/oracle/ordump/logs/CS_cron.log"


Pls help me to resolve the logfile issue which going to default.


Any help on this is highly appreciated

Thanks
-Dave
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-12-2011, 10:40 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Two things ...

You forgot the actual redirect in your script.
It's
Code:
* 3 * * * /home/oracle/scripts/exp.sh 2>&1 > /home/oracle/ordump/logs/CS_cron.log
, not
Code:
* 3 * * * /home/oracle/scripts/exp.sh 2>&1 /home/oracle/ordump/logs/CS_cron.log
And are you sure you need to run that script so many times, every minute from 03:00 till 03:59?


Cheers,
Tink

Last edited by Tinkster; 12-12-2011 at 10:42 AM.
 
2 members found this post helpful.
Old 12-12-2011, 10:43 AM   #3
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
Code:
/home/oracle/scripts/exp.sh 2>&1 /home/oracle/ordump/logs/CS_cron.log
that pipes stderr to stdout and gives a parameter -- which the script never even looks at. I think you want
Code:
/home/oracle/scripts/exp.sh >/home/oracle/ordump/logs/CS_cron.log 2>&1

Last edited by jthill; 12-12-2011 at 10:52 AM. Reason: &> is a bashism, removed.
 
1 members found this post helpful.
Old 12-13-2011, 07:16 AM   #4
daveant
LQ Newbie
 
Registered: Dec 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
Hi all,

Thanks for your support.

i have scheduled in the cron in this way.

* 10,13,15,19 * * * /backup-node3/oracle_scripts/exp.sh >> /backup-node3/dmp_cron_logs/exp_cron.log 2>&1

unfortunately the export is running at every minute. i want to schedule it at moring 10, afternoon 1 clok ,evening 3 and 7o clock at evening.

Pls give me some input on this

Thanks in Advance

-Dave
 
Old 12-13-2011, 07:30 AM   #5
zQUEz
Member
 
Registered: Jun 2007
Distribution: Fedora, RHEL, Centos
Posts: 294

Rep: Reputation: 54
change
Quote:
* 10,13,15,19 * * * /backup-node3/oracle_scripts/exp.sh >> /backup-node3/dmp_cron_logs/exp_cron.log 2>&1
to
Quote:
0 10,13,15,19 * * * /backup-node3/oracle_scripts/exp.sh >> /backup-node3/dmp_cron_logs/exp_cron.log 2>&1
 
1 members found this post helpful.
Old 12-14-2011, 12:10 AM   #6
daveant
LQ Newbie
 
Registered: Dec 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thank you all. I resolved my issues.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] help with cron job frieza Linux - Software 10 06-16-2011 10:49 PM
linux cron job duplicate job question cpthk Linux - Newbie 4 09-11-2009 08:52 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
Cron Job petenyce Linux - Newbie 5 10-11-2005 04:03 PM
cron job working2hard Programming 6 07-28-2004 09:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration