Home » Other » General » Job at crontab is not running (11g, 11.2.0.1, red-hat 5)
Job at crontab is not running [message #593687] Tue, 20 August 2013 00:40 Go to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear All,

I have scheduled the backup in crontab. But its not running at the mentioned scheduled time.
Below is the crontab details -

root:/root>crontab -l
20 11 * * * sh /usr/backup/RMAN/rman_full_backup.sh
root:/root>



Below are the details -

oracle:/usr/backup/RMAN>date
Tue Aug 20 11:20:05 IST 2013
oracle:/usr/backup/RMAN>ls
rman_full_backup.sh  TAGITEST
oracle:/usr/backup/RMAN>pwd
/usr/backup/RMAN
oracle:/usr/backup/RMAN>


While running manually, it's running. Please assist me where the problem is?

Regards,
Ishika
Re: Job at crontab is not running [message #593688 is a reply to message #593687] Tue, 20 August 2013 00:47 Go to previous messageGo to next message
John Watson
Messages: 8960
Registered: January 2010
Location: Global Village
Senior Member
Under what operating system account do you think the job will run? Does your script set any environment variables?
Re: Job at crontab is not running [message #593689 is a reply to message #593688] Tue, 20 August 2013 00:59 Go to previous messageGo to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear John,

My script is as below -


export PATH=/usr/oracle/app/oracle/product/11.2.0/dbhome_1/bin
export ORACLE_SID=TAGITEST
export ORACLE_HOME=/usr/oracle/app/oracle/product/11.2.0/dbhome_1
rman target / << EOF

run {
            allocate channel c1 type disk;
                report schema;
                crosscheck backup of database;
                crosscheck backup of archivelog all;
                crosscheck backup of controlfile;
                crosscheck backup of spfile;
                crosscheck archivelog all;
                delete noprompt force expired backup;
                delete noprompt force expired archivelog all;
                delete noprompt force expired copy;
                delete noprompt force obsolete;
            release channel c1;
        }

        run {
            allocate channel c1 type disk;
            allocate channel c2 type disk;
                backup format '/usr/backup/RMAN/DataFile_%t_%s.dbf' database;
                backup current controlfile format '/usr/backup/RMAN/control_%t_%s.ctl' ;
                backup format '/usr/backup/RMAN/TAGITEST/Arch_%t_%s.arc' archivelog all;
            release channel c1;
            release channel c2;
        }

        run {
            allocate channel c1 type disk;
                delete noprompt force obsolete;
                crosscheck backup;
                crosscheck archivelog all;
            release channel c1;
        }

        run {
            report need backup;
            report unrecoverable;
        }
        list backup summary;
        list backupset;
        list backup of controlfile;

        exit;



It is running manually. Now, suggest me

Regards,
Ishika
Re: Job at crontab is not running [message #593690 is a reply to message #593689] Tue, 20 August 2013 01:02 Go to previous messageGo to next message
John Watson
Messages: 8960
Registered: January 2010
Location: Global Village
Senior Member
I have already given you two suggestions.
Re: Job at crontab is not running [message #593692 is a reply to message #593687] Tue, 20 August 2013 01:28 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Is crontab deamon running? (ps -eaf | grep crond)
Have you the right to use crontab? (cat /etc/cron.allow /etc/cron.deny)

Regards
Michel
Re: Job at crontab is not running [message #593696 is a reply to message #593692] Tue, 20 August 2013 02:25 Go to previous messageGo to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear Michel,

Below are the details... Cron files are having only rights to root.

oracle:/etc>ps -ef|grep crond
root      7113     1  0 Jul17 ?        00:00:00 crond
oracle   29192 22856  0 13:06 pts/2    00:00:00 grep crond


oracle:/etc>ls -ltr cron*
-rwxrwxrwx 1 root root  255 Jul 15  2006 crontab
-rwxrwxrwx 1 root root    0 Jul  8  2008 cron.deny

cron.hourly:
total 0

cron.monthly:
total 8
-rwxr-xr-x 1 root root 381 Dec 18  2006 0anacron

cron.weekly:
total 16
-rwxr-xr-x 1 root root 414 Jul 13  2006 makewhatis.cron
-rwxr-xr-x 1 root root 380 Dec 18  2006 0anacron

cron.daily:
total 84
-rwxr-xr-x 1 root root 2181 Jun 21  2006 prelink
-rwxr-xr-x 1 root root  133 Jul 13  2006 00webalizer
-rwxr-xr-x 1 root root  418 Jul 13  2006 makewhatis.cron
-rwxr-xr-x 1 root root  290 Nov 26  2006 tmpwatch
-rwxr-xr-x 1 root root  137 Nov 26  2006 mlocate.cron
-rwxr-xr-x 1 root root  379 Dec 18  2006 0anacron
-rwxr-xr-x 1 root root  180 Oct 22  2007 logrotate
-rwxr-xr-x 1 root root 1042 Jan 11  2008 certwatch
-rwxr-xr-x 1 root root  114 Jan 15  2008 rpm
-rwxr-xr-x 1 root root  118 Mar 20  2008 cups
lrwxrwxrwx 1 root root   39 Jul  8  2008 0logwatch -> /usr/share/logwatch/scripts/logwatch.pl

cron.d:
total 12
-rw-r--r-- 1 root root 188 Nov 22  2006 sysstat
-rw------- 1 root root 366 Jan  7  2008 sa-update



Regards,
Ishika
Re: Job at crontab is not running [message #593702 is a reply to message #593696] Tue, 20 August 2013 03:36 Go to previous messageGo to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear All,

I have scheduled another job and it is running -

oracle:/usr/backup>ls
dp_dir  impdp_TAGIC_general_39.152.sh  imp.sh  [b]imp_show.sh[/b]  RMAN  tablespace_39_152.sql  tablespace.sql.txt
oracle:/usr/backup>date
Tue Aug 20 14:14:54 IST 2013
oracle:/usr/backup>[b]ls /bkup/logs/DB_REFRESH1[/b]
chkdb.log            compile_ins.sql    compile_reins.sql  grant_frm_usr.sql    synonym_ins.sql     user_grant.sql
compile_confsys.sql  compile_other.sql  grant_frm_sys.sql  synonym_confsys.sql  synonym_others.sql
oracle:/usr/backup>


root:/root>crontab -l
01 14 * * * sh /usr/backup/imp_show.sh
root:/root>


echo .
echo                  +-----------------------------------------+
echo                  Database Refresh Utility
echo             +-----------------------------------------+
echo .
echo .
echo .
echo .
echo
export ORACLE_HOME=/usr/oracle/app/oracle/product/11.2.0/dbhome_1;
export ORACLE_SID=TAGITEST;
echo "Enter the database name :"
read dbnm
export ORACLE_SID=$dbnm
echo "Enter the datapump name: "
read dmpnm
export DUMP_FILE=$dmpnm
rm -rf /bkup/logs/DB_REFRESH1/*
echo .
mkdir -p /bkup/logs/DB_REFRESH1/
echo "grant CREATE RULE to ins,confsys,reins ;"       >>/bkup/logs/DB_REFRESH1/user_grant.sql
echo "grant CREATE SEQUENCE to ins,confsys,reins ;"   >>/bkup/logs/DB_REFRESH1/user_grant.sql
echo "grant CREATE SESSION to ins,confsys,reins ;"    >>/bkup/logs/DB_REFRESH1/user_grant.sql
echo "grant CREATE SNAPSHOT to ins,confsys,reins ;"   >>/bkup/logs/DB_REFRESH1/user_grant.sql


Here, schedule is running. Then,why my previuos schedule is not running?
Please help me out to know the problem on it.

Regards,
Ishika

Re: Job at crontab is not running [message #593712 is a reply to message #593702] Tue, 20 August 2013 05:18 Go to previous messageGo to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear Mr. John/Michle,

Please suggest me why my backup is not running?

Under linux operating system account will run the job.

Regards,
Ishika
Re: Job at crontab is not running [message #593716 is a reply to message #593687] Tue, 20 August 2013 05:35 Go to previous messageGo to next message
gazzag
Messages: 1119
Registered: November 2010
Location: Bedwas, UK
Senior Member
You say that you can run it manually but you say when it is run by cron: Quote:
not running at the mentioned scheduled time
.

So does it run at all under cron and just not at the expected time?
Re: Job at crontab is not running [message #593734 is a reply to message #593687] Tue, 20 August 2013 08:42 Go to previous messageGo to next message
Ricky_1362002
Messages: 111
Registered: February 2009
Senior Member
Ishika,

Why not try logging your cronjob?
And see what the log has in it.

20 11 * * * sh /usr/backup/RMAN/rman_full_backup.sh 2>&1 >> /var/log/myjob.log


You might have already checked with the permissions on the file, but just in case, if you haven't, check the permissions on the file as well.

And BTW....you said
Quote:

Please suggest me why my backup is not running?

But, I DO NOT see any BACKUP in your script, it's just the report, if I am not wrong.

And as far as I know, cronjobs are run in the background, and when you run such scripts (reporting/listing the backups), you cannot see them, you might be able to see the output of your script(when run as a cronjob) if you log it.

Do keep us posted.

Thanks,
Rik

[Updated on: Tue, 20 August 2013 08:55]

Report message to a moderator

Re: Job at crontab is not running [message #593752 is a reply to message #593688] Tue, 20 August 2013 11:14 Go to previous messageGo to next message
John Watson
Messages: 8960
Registered: January 2010
Location: Global Village
Senior Member
I told you what the problem was hours ago, man. You are trying to run these jobs under the wrong operating system account. You can't run RMAN as root.
Re: Job at crontab is not running [message #593787 is a reply to message #593752] Tue, 20 August 2013 23:29 Go to previous messageGo to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear John,

From your previous reply. I was not able to understand about the "what operating system account do you think the job will run" but yesterday I found the answer what ever you said later "You can't run RMAN as root".

Yes ! we can't run RMAN schedule through root user as schedule back has to run by oracle.

While issuing command "crontab -l" through oracle user, i am getting error "premission denied".

Once, it get rectified. Hope, my schedule will run.

Thanks for clarifying me John.

I will keep posting the observation and solution of this error( if it's solved )

Regards,
Ishika
Re: Job at crontab is not running [message #593829 is a reply to message #593787] Wed, 21 August 2013 05:18 Go to previous messageGo to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear All,

To resolve the permission issue through oracle. I have done the activities -

Steps to resolve "cron/oracle: Permission denied" problem

1) On /etc
Log in as a root
firstly, check whether cron.allow file is available or not. If available, check whether user is available in it or not?
In our case, file was not available.
cron.allow file is created and inserted oracle & root user in it.

root:/etc> vi cron.allow

root:/root> cat /etc/cron.allow
root
oracle


2) Provide full access on crontab to all.

root:/etc> chmod 777 crontab

3) On /usr/bin
Log in as a root , and find the permission as given by,

root# ls -l /usr/bin/crontab

-rwxr-xr-x 1 root root 315432 Jul 15 2008 /usr/bin/crontab

root# chmod 4755 /usr/bin/crontab

root# ls -l /usr/bin/crontab

-rwsr-xr-x 1 root root 315432 Jul 15 2008 /usr/bin/crontab


By doing this, my problem got solved.

I will let you know once, my scheduled back run.

Just sharing !!!

Regards,
Ishika

Re: Job at crontab is not running [message #593837 is a reply to message #593829] Wed, 21 August 2013 05:51 Go to previous messageGo to next message
gazzag
Messages: 1119
Registered: November 2010
Location: Bedwas, UK
Senior Member
Thanks for the feedback, but only root needs to write to crontab as it is read/written by the cron daemon (crond) which runs as root. More accurate would be:

# chmod 644 /etc/crontab


Changing permissions on /usr/bin/crontab is unadvisable too. It should be:

-rwsr-sr-x


HTH
-g

[Edit: addendum]

[Updated on: Wed, 21 August 2013 06:35]

Report message to a moderator

Re: Job at crontab is not running [message #593868 is a reply to message #593837] Wed, 21 August 2013 09:01 Go to previous message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
Dear Ricky / Gazzag And All,

Thanks for responding and assisting.

After doing all changes. My Rman scheduling is running through oracle users.

Regards,
Ishika
Previous Topic: Documentation
Next Topic: Difference between Oracle Enterprise Software cost and License Cost
Goto Forum:
  


Current Time: Mon Nov 25 22:33:30 CST 2024