script not working in CRON


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script not working in CRON
# 1  
Old 07-11-2006
MySQL script not working in CRON

guys

i have written a very simple script .it runs manually well.
but when i put it in cron,it doesn't give the desired output.

script looks like this:

#! /usr/bin/sh
#script for loading data in table using ctl file/Abhijeet K/08.07.2006

/svm_wl1/. .profile
cd /svm_wl1/billing/data/server/log

rm SVM_WL1_WLN_DATA_USAGE.txt

a=`ls SVM_WL1_WLN_DATA_USAGE_2006*.txt`
echo "----------"
echo $a
echo "----------"
sleep 5

cp $a /svm_wl1/billing/data/server/archive/SVM_WL1_WLN_DATA_USAGE

echo $a > /svm_wl1/billing/data/server/log/test
b=`cut -b 1-22 /svm_wl1/billing/data/server/log/test`
echo "------------"
echo $b
echo "------------"
rm test
sleep 5
mv $a $b.txt

sqlldr <username>/<password>@<database_name> control=/svm_wl1/billing/data/server/log/DIA_USAGE.ctl log=/svm_wl1/billing/data/server/log/DIA_USAGE.log


echo "------"
echo "done"
echo "------"
date
echo "------"


If a run script manullay,data gets inserted in the table & a log file also gets generated but in cronjob script runs without insertion and log file generation.

i tried calling . .profile before the execution of script starts.
still no result.

any views/suggestions/corrections welcome

regards
abhijeet
# 2  
Old 07-11-2006
Hi

Are you sure your script is being called. How you have define in CRON entry.

Thanks
# 3  
Old 07-11-2006
MySQL

yup
script is getting called. i am redirecting echo statements in a .txt file.

00 05 * * * /svm_wl1/billing/data/server/log/sqlldr.sh > /svm_wl1/billing/data/server/log/sqlldr.txt

this txt file gets modified on the scheduled time.
but data is not getting inserted in the table.

i feel it has something to do with the cron enviroment.
does cron sets up its own enviroment?

i have been facing cron problem for some time now.i write scripts,they run manually but fail in cron.


o/p of sqlldr.txt file is like this:

----------
SVM_WL1_WLN_DATA_USAGE_2006-07-10.txt
----------
------------
SVM_WL1_WLN_DATA_USAGE
------------
------
done
------
Tue Jul 11 05:00:10 IST 2006
------
# 4  
Old 07-11-2006
# 5  
Old 07-11-2006
Please set your oracle home path from where you are connecting.

Thanks
# 6  
Old 07-13-2006
MySQL

the problem is resolved.
i sourced the ".profile" of the user & it has worked.
thanks for the support.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pattern not working in Cron script

Hi, I have written a shell script to list all the files with some pattern as below. <CODE> ls *_20151201*.txt <CODE> its working properly when ran manually. But when i tried to run by cronning it.. its throwing an error that no files exists with file name *_20151201*.txt But when I try... (3 Replies)
Discussion started by: ssk250
3 Replies

2. Shell Programming and Scripting

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: # more... (4 Replies)
Discussion started by: nypreH
4 Replies

3. 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

4. UNIX for Dummies Questions & Answers

Email Script not working when added to cron[solved]

Hi I have written an email script in python which sends email to the given id. I have customized the script for generating space alert inside a shell script as shown below df -h /microfocus > /tmp/spacereport ## Filter the %usage to variable per per=$(awk '{if (NR==3){print $4}}'... (0 Replies)
Discussion started by: rakeshkumar
0 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

stdout redirect is working buy direct script exec but not in cron

Hi @ all :) i made a very little shell script witch is working well when i'm launching it directly like with ./script but when i'm launching it by cron tab it work at half only. the part of the script witch are not working are: #!/bin/sh apt-get updade apt-get -s upgrade >>... (5 Replies)
Discussion started by: calibal
5 Replies

7. Shell Programming and Scripting

Shell script not working in cron

Hello, I know little about shell scripting and creating a script, and worked fine in the command line. But not work in the cron. Below you could see the script #!/bin/sh LOGFILE=/home/transfield/mou/test.log # Find yesterday Date and copy files TODAY=$(date --date= +%F) YESTERDAY=$(date... (4 Replies)
Discussion started by: malikp
4 Replies

8. Shell Programming and Scripting

Script not working when called by cron

Hello, I have the following script which works fine when ran from the command line: #!/apps/python/2.3.4/bin/python import os import sys import time user = os.getenv("USER") string = time.strftime("%m%d%y0000 " + user, time.gmtime()) However, when I have this run by crontab, I... (4 Replies)
Discussion started by: cooldude
4 Replies

9. Shell Programming and Scripting

sudo command is not working inside a script when placed in cron

Hi All, i have a cron entry like 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /amex/sssmonitor/dss_chk.ksh and the script is like #!/bin/ksh file=`uname -n` > /sunmast/projects/oasis/COREDEV/Dss$file.log > /tmp/output_sss today=`date` varb=`ps -ef | grep... (5 Replies)
Discussion started by: usha rao
5 Replies

10. Shell Programming and Scripting

running script in cron - with ssh commands - not working

I ran an ssh command to run a script on a remote server ssh -l <user> <servername> /path/to/script/scriptname This works fine - and the script is executed correctly. However - I put this command into a script, that I want to run from cron every hour, to execute the file on the remote... (31 Replies)
Discussion started by: frustrated1
31 Replies
Login or Register to Ask a Question