Tuesday, 2 August 2016

Crontab not sending mail , Crontab not running script

Hello ,

Today I am here to tell about the major problem which every one faced while configuring crontab.
We see our script running manually but through crontab it's not running properly.

There is only one solution to this problem i.e to add environment variables in your script.

For example -

Here is one file Test.sh. it contains following lines.

#!/bin/bash
sqlplus  /nolog  @/path/test.sql | mail -s "status" Saurabht904@gmail.com

Maually this script is running .

But when I tried to run through it crontab nothing was happening. I was getting blank mail only.

Then I added my environment variable on top of script.

Like this -

#!/bin/bash
export PATH=/home/oracle/product/11.2.0/OPatch:/usr/bin:/usr/local/bin:
/bin:/usr/bin:/export/home/oracle/bin:/export/home/oracle/product/bin:
/export/home/oracle/product/11.1.0
export ORACLE_BASE=/export/home/oracle
export ORACLE_HOME=/export/home/oracle/product/11.2.0
export ORACLE_SID=Test
sqlplus  /nolog  @/path/test.sql | mail -s "status" Saurabht904@gmail.com

This time my script is creating file and sending data through mail . :)


So always remember to set environment variable if your crontab is not working properly.


Thanks For Reading this Post.

You can write me mail on Saurabht904@gmail.com.....





 

Tuesday, 23 February 2016

Not able to connect as rman catalog "RMAN-04004: error from recovery catalog database: ORA-12154: TNS:could not resolve the connect identifier specified"

Hi,

If you have created catalog user and you want to connect to rman with that user and you are getting the following error-

RMAN-04004: error from recovery catalog database:
ORA-12154: TNS:could not resolve the connect identifier specified

see below errors--

rman catalog = catalog/metalog@catdb
Recovery Manager: Release 11.2.0.3.0 - Production on Tue Feb 23 15:02:03 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04004: error from recovery catalog database: ORA-12154: TNS:could not resolve the connect identifier specified


I thing you are trying with connect identifier on same machine on which you have database like @catdb in this command.

Action - Don't use @catdb because if you are using same server to connect there is no need to give connect identifier.

export ORACLE_SID=catdb
-bash-4.1$ rman catalog = catalog/metalog

by giving this you will easily connect to your rman.

If you are trying to connect to  catalog database on different host then you have to create tns entry in tnsnames.ora file .


like  ----

catdb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = hostname )(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID = DB_NAME)

Thanks

If  You have any query please comment your query.


 

Monday, 8 February 2016

ORA-01940: cannot drop a user that is currently connected

SQL> DROP USER test CASCADE;
DROP USER test CASCADE
*
ERROR at line 1:
ORA-01940: cannot drop a user that is currently connected




Reason - User connected to the database.To Drop user ask user to disconnect or Do
it by yourself.

To Disconnect the session .Check for the SID and SPID using this command-

SELECT s.sid, s.serial#, s.status, p.spid   FROM v$session s, v$process p  WHERE s.username = 'test'   AND p.addr(+) = s.paddr  /

It will Give output like this---

       SID    SERIAL# STATUS   SPID ---------- ---------- -------- ------------------------        162          9 ACTIVE   29613

Now Use this command to kill session.

alter system kill session 'SID,SPID';

alter system kill session '162,9';

It may take time to kill session.

Thanks For reading this blog. -Saurabh


 

ORA-00018: maximum number of sessions exceeded

cause - Whatever value you specified for SESSIONS  in parameter file .sessions created till that value.

action - Increase the value of  SESSIONS in Parameter files.

Try This -

1. alter system set sessions = 'VALUE' scope=spfile;
2. alter system set sessions = 'VALUE' scope=pfile;
3. alter system set sessions = 'VALUE' scope=both;