Solved

crontab not executing

Posted on 2014-04-06
8
415 Views
Last Modified: 2014-04-06
this is my shell

#/bin/ksh

dummy=`sqlplus -s  'sakthi_r/gcp_ro_access@(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.19.56)(PORT = 1780))
        (CONNECT_DATA =
              (SERVER = DEDICATED)
                    (SERVICE_NAME = DPWGCP)
                        )
                          )'  <<EOF
                          SET HEA OFF PAGES 0
                              select count(*) from gcb_dba.gcb_charge_dtls ;
                             EXIT;
                             EOF`

                          print "${dummy}"

                              if [ "$dummy" -gt 1 ]; then
                                # mailx -s "Something bad happened in production" ITPeople.SakthiKumar@dpworld.com
                                echo "something" | mailx -s "subject" ITPeople.SakthiKumar@dpworld.com
                                    print "1"
                                     fi

                                     sqlplus 'system/system@dcsss'  << EOF

                                         insert into abcd values (1);
                                         commit;
                                         exit;
                                         EOF



and this is my cron tab entry

21,22,23,24,25,26,27,28,29,30,31,45,46,47,48,49,50,51,52,53,54,55 * * * * /home/opctusr1/test/new.ksh >> /home/opctusr1/test/test.log


time of the test.log is changing. but my crontab job is not executing.

when I try to execute normally, it is fine. but only from cron job it is not executing.

Please help me resolve this.
0
Comment
Question by:sakthikumar
  • 4
  • 4
8 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
Comment Utility
Please note for crontab scripts, you need to:

1- set all required env variables
2- use full path names to files and dires
3- redirect stdin, stdout, and stderr
4- Make sure that the script is executable

Make sure to run the script with the right user (e.g. oracle)
0
 

Author Comment

by:sakthikumar
Comment Utility
Which environment variables i need to set.?
 I have given 777 privs to user.
how can I get / identify the full path.
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 500 total points
Comment Utility
Please look in the user's home directory for .profile file and see what env variables ae set. You may set PATH and Oracle env. as example.

One quick way is to run commands like

set

and

env

and see relevant env variables required.


Also, if you don't set PATH then you need to use full path name to commands like sqlplus, mailx, etc.
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 500 total points
Comment Utility
For you to get the full path name for commands, you may run command

which sqlplus

which mailx
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:sakthikumar
Comment Utility
Hi

I have added the below lines in my shell script.

ORACLE_SID=DCSSS
export ORACLE_SID
ORACLE_HOME=/u01/app/oracle/products/OAS/10.2/BI_Forms
export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin
export PATH


But still I am getting the error.
when I tried which sqlplus
/u01/app/oracle/products/OAS/10.2/BI_Forms/bin/sqlplus

In the log, I am getting error.
sqlplus not found
0
 

Author Comment

by:sakthikumar
Comment Utility
I am a beginner in unix, please tell me exactly where should I execute what commands to get it right..
0
 

Author Comment

by:sakthikumar
Comment Utility
Thank you very much Omar, I got it atlast.
0
 
LVL 40

Expert Comment

by:omarfarid
Comment Utility
Welcome :)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now