LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-30-2017, 03:38 AM   #1
Natarajachar
LQ Newbie
 
Registered: Oct 2016
Posts: 13

Rep: Reputation: Disabled
Crontab not working as expected for one script


Hi guys,

I have defined cronjob in my SLES10 server which runs RMAN for archival of archive logs. The crontab looks like this:

00,20,40 * * * * /u02/backup/rman/rman_archive_del.sh>>/u02/backup/rman/rman_archive_del1.log

When I run the script manually, the script will invoke RMAN and do the job well but when I leave it for crontab to run it, it is not invoking RMAN itself.

The same script is working fine in another linux server.

Thanks&Regards,
Natraj
 
Old 11-30-2017, 03:45 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,879

Rep: Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910
I think this is the usual crontab issue:
1. use full path in your script to invoke rman (and others)
2. save stderr somewhere to see what's happened, otherwise we can only guess.
 
Old 11-30-2017, 04:55 AM   #3
Natarajachar
LQ Newbie
 
Registered: Oct 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
Hi,

Thanks for the reply.
I added the path of rman. Still the issue remains.

Regards,
Natraj
Attached Files
File Type: txt script.txt (496 Bytes, 10 views)
File Type: txt rman log.txt (938 Bytes, 6 views)
 
Old 11-30-2017, 05:02 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,879

Rep: Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910Reputation: 2910
you can insert set -xv at the beginning of the script to see what's happening.
And also use bash to start your script:
Code:
00,20,40 * * * * /bin/bash /u02/backup/rman/rman_archive_del.sh>>/u02/backup/rman/rman_archive_del1.log
 
Old 12-01-2017, 01:35 AM   #5
Natarajachar
LQ Newbie
 
Registered: Oct 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
Thanks for the reply.
The same script is running well on another server but it is not running on this machine. Please help.
 
Old 12-01-2017, 01:38 AM   #6
Natarajachar
LQ Newbie
 
Registered: Oct 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
Hi,

After making the changes as suggested by you previously, the cronjob is invoking RMAN. But it is throwing error when it runs automatically.

***********Archive file deletion started at Fri Dec 1 14:50:00 IST 2017***********


Recovery Manager: Release 10.1.0.4.2 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

RMAN>
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
ORA-12162: TNS:net service name is incorrectly specified

RMAN>
connected to recovery catalog database

RMAN> RMAN> RMAN> RMAN> RMAN> The archival process ended at Fri Dec 1 14:50:00 IST 2017

Where as when I run thye same script manually, it works fine.

***********Archive file deletion started at Fri Dec 1 14:51:02 IST 2017***********


Recovery Manager: Release 10.1.0.4.2 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

RMAN>
connected to target database: CONPRDDB (DBID=2379791943)

RMAN>
connected to recovery catalog database

RMAN> RMAN> RMAN> RMAN> RMAN> The archival process ended at Fri Dec 1 14:51:10 IST 2017

Regards,
Natraj
 
Old 12-05-2017, 01:55 PM   #7
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 287

Rep: Reputation: 41
Cron run its jobs in so called "sanitized" environment. You can read about this in it's manual.
You should source your .bashrc (or .profile or what suits) at beginning of script.
 
Old 12-07-2017, 10:59 AM   #8
dlopen
LQ Newbie
 
Registered: Dec 2017
Posts: 2

Rep: Reputation: Disabled
I would insert debug statements at the beginning of the script:

date >> /path-to-log
set >> /path-to-log

And then compare environment variables when run manually and via cron.
 
Old 12-08-2017, 04:40 PM   #9
dfreybur
LQ Newbie
 
Registered: Aug 2017
Location: Austin, TX, US
Posts: 6

Rep: Reputation: Disabled
The script finds all of the binaries. Look closely at the error message in the log you posted -

ORA-12162: TNS:net service name is incorrectly specified

That means your tnsnames.ora file is missing, does not contain the SID connection string, is in the wrong directory, is not readable by the user running the crontab.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
bash script not working as expected when executed at startup kuhnto Linux - Newbie 8 09-26-2017 09:00 PM
[SOLVED] sudo not working as expected on custom script. crwdawg Linux - Security 8 01-31-2013 07:27 AM
[SOLVED] rsyslog upstart script not working as expected grail Ubuntu 3 03-23-2011 08:47 PM
Wireless script not working as expected SlowCoder Linux - General 6 05-24-2008 08:06 AM
Crontab not working as expected nro Linux - Newbie 7 08-29-2005 01:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:33 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration