The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with executing a script scheduled in crontab Amardeep Shell Programming and Scripting 4 07-07-2006 12:51 AM
CRON problem using script... Sorrento Shell Programming and Scripting 0 10-14-2005 12:48 PM
problem with a script and the cron pascalbout AIX 1 10-13-2005 09:42 AM
Conditional File Movement script scheduled using CRON job imu Shell Programming and Scripting 2 09-20-2005 06:30 AM
cron job problem with csh script fung_donald Shell Programming and Scripting 3 04-11-2002 10:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-18-2007
forumthreads forumthreads is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 18
problem when the script is scheduled to run as cron job

Hello,

I have problem in executing a shell script. When the shell script is executed at the shell prompt the script works successfully but when the same script is run as a cron job it fails to execute the files called within the shell script.

I have scheduled the job in my crontab file as

15 4 * * * /apps/scripts/scm_tools/validset/poa_product/software_product/spvs >
/apps/scripts/scm_tools/logs/software_product_vs.log 2>&1

The spvs file contents are

#!/bin/ksh

#Set DMDB to specify the Base Database for Dimenisons PDIFF command
export DMDB=intermediate/intermediate@PVCS


cd /apps/scripts/scm_tools/validset/poa_product/software_product

sqlplus intermediate/intermediate @/apps/scripts/scm_tools/validset/poa_product/software_product/spvs "%"

# write the initial lines to ptvs.txt to create PDIFF control plan Import file - see Dimenison PDIFF document

echo "#PDIFF3" >> spvs.txt
echo "#DATE 07-JUL-2007" >> spvs.txt
echo "#RESERVED" >> spvs.txt
echo "#RESERVED" >> spvs.txt
echo "#RESERVED" >> spvs.txt
echo "#RESERVED" >> spvs.txt
echo "\n" >> spvs.txt
nawk -f spvs.awk dpq.csv >> spvs.txt

echo "END_OBJECT" >> spvs.txt

#PDIFF command to import SOFTWARE_PRODUCT validset values
pdiff POA -load_cpl -d -l spvs.log -f spvs.txt

#clean up
mv *.log archive
mv *.txt archive
mv *.csv archive




The software_product_vs.log file contains

/apps/scripts/scm_tools/validset/poa_product/software_product/spvs[19]: sqlplus: not found
nawk: can't open file spvs.awk
source line number 1
context is
>>> <<<
/apps/scripts/scm_tools/validset/poa_product/software_product/spvs[45]: pdiff: not found
mv: archive not found
mv: archive not found
mv: cannot access *.csv

I am not sure if the problem is because of the child process being created.
All the files used have execute permissions on them.

Appreciate any suggestions on this.

Many Thanks.
  #2 (permalink)  
Old 07-18-2007
lorcan lorcan is offline
Registered User
  
 

Join Date: May 2007
Posts: 219
I suspect that it couldn't recognize the sqlplus and the pdiff command in the script.

So check if you have declared the environmental variables like ORACLE_HOME and PATH. If not then export these variables in your script.

Hope this helps.
  #3 (permalink)  
Old 07-18-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
cron jobs do not run your .profile or equivalent. You must set up any environment you need or source .profile yourself.
  #4 (permalink)  
Old 07-18-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
Sourcing .profile in a cron job is not recommened

Instead, use full path to call bin like sqlplus
  #5 (permalink)  
Old 07-19-2007
forumthreads forumthreads is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 18
Porter,

Many thanks for your help.
  #6 (permalink)  
Old 07-19-2007
forumthreads forumthreads is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 18
matrixmadhan,

Thanks for your help. Can you please tell me what would be the knock on effect of sourcing a .profile file

At the moment I am using my sqlplus as

sqlplus intermediate/intermediate @/apps/scripts/scm_tools/validset/tstcm_product/software_product/spvs "%"

Let me know if i am not using the full path as told by you.
  #7 (permalink)  
Old 07-19-2007
forumthreads forumthreads is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 18
Iorcon,

Many Thanks for your help.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0