Sponsored Content
Top Forums Shell Programming and Scripting Script (with sql queries) not working using cron Post 302716039 by nypreH on Tuesday 16th of October 2012 01:28:20 AM
Old 10-16-2012
Script (with sql queries) not working using cron

Hi all,

I have script, which performing sql queries and put output into file.
When I run this script manually, its working fine, but when I want to schedule it with cron I am getting errors...

I defined LD_LYBRARY_PATH and ,but no result. After I defined it, I am getting error:

Code:
[root@dsafn1 20121016]#  more NOKRWW_PS_INTERSHO_MNC1_RAW-201210160900.csv 
ERROR:
ORA-12545: Connect failed because target host or object does not exist


SP2-0640: Not connected

I tried to define:
Code:
HOST = scv2db.r01.netact.azerfon.az

but got same error.

Here is part of script:

Code:
[root@dsafn1 ttg_project]# more run.sh 
#!/bin/bash  
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/10.2.0.2/client/lib:{/usr/lib/oracle/10.2.0.2/client/lib:{}:/opt/nokia/oss/lib:/opt/nokia/oss/tao/lib:/usr/lib:/usr/lib/or
acle/10.2.0.2/client/lib}:/opt/nokia/oss/lib:/opt/nokia/oss/tao/lib:/usr/lib:/usr/lib/oracle/10.2.0.2/client/lib
export LD_LIBRARY_PATH
PATH=$PATH:/usr/lib/oracle/10.2.0.2/client/bin:/opt/nokia/oss/bin:/opt/nokia/oss/perl/bin:/opt/nokia/oss/tao/bin:/bin:/usr/bin:/usr/lib/oracle/10.2.0.2/client/bin:/opt/nok
ia/oss/bin:/usr/lib/oracle/10.2.0.2/client/bin:/opt/nokia/oss/bin:/opt/nokia/oss/perl/bin:/opt/nokia/oss/tao/bin:/bin:/usr/bin:/usr/lib/oracle/10.2.0.2/client/bin:/opt/nok
ia/oss/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/sbin:/opt/nokia/oss/sbin:/root/bin:/usr/sbin:/opt/nokia/oss/sbin
export PATH
ORACLE_HOME=/usr/lib/oracle/10.2.0.2/client
export ORACLE_HOME
ORACLE_SID=oss
export ORACLE_SID
#
#---------- Creating folder in /root/ttg_project/output with current date --------------
#

cd /root/ttg_project/
mkdir ./output/20`date '+%y%m%d'`
chmod 777 ./output/20`date '+%y%m%d'`
#sleep 30
#
#---------- End of creating folder in /root/ttg_project/output with current date --------------
#


#
#---------- Running Queries with output to /root/project_ttg/output/Current_Date_Folder_Name -----------
#

/usr/lib/oracle/10.2.0.2/client/bin/sqlplus -s /nolog <<EOF > ./output/20`date '+%y%m%d'`/NOKRWW_PS_INTERSHO_MNC1_RAW-20`date --date="1 hour ago"  '+%y%m%d%H'`00.csv
connect rdr/rdr
set linesize 10000
SET PAGESIZE 50000
SELECT  
'RNC_ID'||'|'|| 
'WBTS_ID'||'|'||
..............................
..............................

Could you please let me know where the problem is?
Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SQL queries in background?

I have to query a DB2 database, and sometimes they take a long time to produce results. Can I run these queries in the background, and if so, where will the results appear? (1 Reply)
Discussion started by: jpprial
1 Replies

2. UNIX for Dummies Questions & Answers

Sh Shell Script executing remote SQL queries

Hi there folks, I am trying to execute remote sql queries on an Oracle server. I would like to save the result of the executed sql queries on a text file, and send that text file as an attachment to an email address. Could anyone give me an idea on how the above could be achieved? Any help... (2 Replies)
Discussion started by: Javed
2 Replies

3. UNIX for Dummies Questions & Answers

shell script for sql queries

Hi All, I have written 4 sql queries . Now I want to write one SHELL SCRIPTING program for all these queries... i.e 1.select * from head; 2. select * from detail; 3. delete from head; 4. delete from detail; Please let me know how to write a shell script... Thank you (1 Reply)
Discussion started by: user71408
1 Replies

4. Shell Programming and Scripting

Nested SQL queries within Shell script

Hi, Would someone know if I can fire nested sql queries in a shell script? Basically what I am trying to do is as follows: my_sql=$(sqlplus -s /nolog<<EOF|sed -e "s/Connected. *//g" connect... (2 Replies)
Discussion started by: shrutihardas
2 Replies

5. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

6. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

7. Shell Programming and Scripting

Executing set of sql queries from shell script

Hi All, I tried executing set of queries from shell script but not able to capture the input query in the log file. The code looks something similar to below sqlplus user/pwd@dbname << EOF > output.log $(<inputfile.txt) EOF The above code is capturing the output of queries into... (9 Replies)
Discussion started by: loggedin.ksh
9 Replies

8. Shell Programming and Scripting

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX?

Please share the doc asap as very urgently required. (1 Reply)
Discussion started by: 24ajay
1 Replies

9. Shell Programming and Scripting

run sql queries from UNIX shell script.

How can i run sql queries from UNIX shell script and retrieve data into text docs of UNIX? :confused: (1 Reply)
Discussion started by: 24ajay
1 Replies

10. Shell Programming and Scripting

Storing multiple sql queries output into variable by running sql command only once

Hi All, I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise. Eg : Select 'Query 1 output' from dual; Select 'Query 2 output' from dual; I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies
dspam_maintenance(1)						   User Commands					      dspam_maintenance(1)

NAME
dspam_maintenance - remove old signatures and unimportant tokens from the DSPAM storage backend SYNOPSIS
dspam_maintenance [--profile=PROFILE] [--logdays=no_of_days] [--signatures=no_of_days] [--neutral=no_of_days] [--unused=no_of_days] [--hapaxes=no_of_days] [--hits1s=no_of_days] [--hits1i=no_of_days] [--without-sql-purge] [--with-sql-automatization] [--with-sql-autoup- date] [--purgescriptdir=directory] [--with-all-drivers] [--verbose] DESCRIPTION
dspam_maintenance is used to remove old signatures/tokens and unimportant tokens from the DSPAM storage backend and purge old log entries in user and system logs. This script can be called from the command line or run from within cron. Either add a line in your crontab or add this script in your cron.{hourly,daily,weekly,monthly}. Running this script every hour might not be the best idea but it's your decision if you want to do so. OPTIONS
--profile=PROFILE Specify a storage profile from dspam.conf. The storage profile selected will be used for all database connectivity. NOTE: See dspam.conf for more information. --logdays=no_of_days All log entries older than no_of_days days will be removed. NOTE: Default is 31 days. (for more info: man dspam_logrotate) --signatures=no_of_days All signatures older than no_of_daysdays will be removed. NOTE: Default value is set by the PurgeSignatures option in dspam.conf, if this option is not set, the default value is 14 days. This option is only used for the Hash driver. --neutral=no_of_days Deletes all tokens from the target users database whose probability is between 0.35 and 0.65 (fairly neutral, useless data). NOTE: Default value is set by the PurgeNeutral option in dspam.conf, if this option is not set, the default value is 90 days. --unused=no_of_days Remove stale tokens which have not been used for a long period of time. NOTE: Default value is set by the PurgeUnused option in dspam.conf, if this option is not set, the default value is 90 days. --hapaxes=no_of_days Remove tokens with a total hit count below 5 (which will be assigned a hapaxial value by DSPAM). NOTE: Default value is set by the PurgeHapaxes option in dspam.conf, if this option is not set, the default value is 30 days. --hits1s=no_of_days Remove tokens with a single SPAM hit. NOTE: Default value is set by the PurgeHits1S option in dspam.conf, if this option is not set, the default value is 15 days. --hits1i=no_of_days Remove tokens with a single INNOCENT hit. NOTE: Default value is set by the PurgeHits1I option in dspam.conf, if this option is not set, the default value is 15 days. --without-sql-purge Do not use SQL based purging. Only run dspam_clean. NOTE: Default is off (aka: use SQL based purging). --with-sql-optimization Run VACUUM (for PostgreSQL/SQLite) and/or OPTIMIZE (for MySQL). NOTE: Default is off (aka: do not use optimizations). --with-sql-autoupdate Run SQL based purging with purge day values passed to dspam_maintenance. NOTE: Default is off (aka: do not attempt to modify SQL instructions). --purgescriptdir=directory Space separated list of directories where to search for SQL files used for the SQL based purging. --with-all-drivers Process all installed storage drivers (not just the active driver). NOTE: Default is true (aka: process all installed drivers). --verbose Verbose output while running maintenance script. EXIT VALUE
0 Operation was successful. other Operation resulted in an error. Run the script with --verbose to get more information about error. COPYRIGHT
Copyright (C) 2002-2010 DSPAM Project All rights reserved. For more information, see http://dspam.sourceforge.net. SEE ALSO
dspam(1), dspam_admin(1), dspam_clean(1), dspam_crc(1), dspam_dump(1), dspam_logrotate(1), dspam_merge(1), dspam_stats(1), dspam_train(1) dspam_maintenance Apr 26, 2010 dspam_maintenance(1)
All times are GMT -4. The time now is 07:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy