problem when the script is scheduled to run as cron job


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers problem when the script is scheduled to run as cron job
# 1  
Old 07-18-2007
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  
Old 07-18-2007
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  
Old 07-18-2007
cron jobs do not run your .profile or equivalent. You must set up any environment you need or source .profile yourself.
# 4  
Old 07-18-2007
Sourcing .profile in a cron job is not recommened

Instead, use full path to call bin like sqlplus
# 5  
Old 07-19-2007
Iorcon,

Many Thanks for your help.
# 6  
Old 07-19-2007
Porter,

Many thanks for your help.
# 7  
Old 07-19-2007
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cron job scheduled is running once, but reports are generating twice

Team, Hope you all are doing fine I have one admin server which is being used dedicately to run cron jobs on hourly basis, fetching the details from Database which is in a different server.These cronjob are run on every hourly/5 minutes basis depending as per end user requirement.The script... (12 Replies)
Discussion started by: whizkidash
12 Replies

2. Shell Programming and Scripting

Script that will send an email if the cron job did not run.

Team, Would like to know what is the best script that will send you an email if cronjob did not run. Thanks (4 Replies)
Discussion started by: kenshinhimura
4 Replies

3. Shell Programming and Scripting

run unix script as scheduled job

Hi, I want my unix script to run as a scheduled job such that the script is invoked once every 15 minutes. Is there any way to achieve this other than running the script as a cron job? (2 Replies)
Discussion started by: vignesh53
2 Replies

4. Shell Programming and Scripting

how do I run bash script using cron job

How do I run bash script using a cron job? I have tried to just write the path of the script, but that didn't work. (1 Reply)
Discussion started by: locoroco
1 Replies

5. Solaris

Shell Script gives error when run through cron job.

Hi, The following shell script runs without any problem when executed manulally. USED=$(df -h /arch | tail -1 | awk '{print $5}' | cut -d '%' -f 1) if then find /arch/AUBUAT/ -type f -mtime +0 | xargs rm find /arch/AUBMIG/ -type f -mtime +0 | xargs rm fi But the same gives below... (6 Replies)
Discussion started by: ksadiq79
6 Replies

6. UNIX for Advanced & Expert Users

Need help with a script run by a cron job.

Hi, new to this forum and not sure if this is the right place to post. I'm new to cron jobs and scripts, and I need some help with a script to be used with a cron job. I already have a bot set up at a certain website address and need a script that the cron job will load every day that tells it to... (1 Reply)
Discussion started by: klawless
1 Replies

7. Shell Programming and Scripting

script wont run from cron job

I have written a simple bash script that will run a wget command to recursively ftp an entire directories and it's contents. #!/bin/bash wget -r -N ftp://user:pass@server//VOL1/dir If I run from the regular command line it works fine. root@BUSRV: /media/backup1$ ./gwbu When I put it in... (1 Reply)
Discussion started by: mgmcelwee
1 Replies

8. UNIX for Dummies Questions & Answers

shell script run by user or cron job ?

My shell script runs fine both as a cron job and when i issue it. However, I wish to differentiate when it runs as a cron-job so the "echo" statements are not issued (they get mailed to me, which i don't want). I tried checking $USER but since the cron was created in my user that does not... (5 Replies)
Discussion started by: sentinel
5 Replies

9. Shell Programming and Scripting

Conditional File Movement script scheduled using CRON job

Hi All, i am trying to automate a process and have to create a unix script like wise. I have a scenario in which i need to automate a file movement. Below are the steps i need to automate. 1. Check whether a file (Not Fixed name-Pattern search of file say 'E*.dat') is present in a... (2 Replies)
Discussion started by: imu
2 Replies

10. UNIX for Advanced & Expert Users

Run cron job problem

I have the below crontab job that it will run at every 7:00am - 10:00am , it work fine , now if I want to skip to run the crontab job at a specific time , eg. I want the script not to run at next Monday 8:00am ( only skip this time , other time is normal ) , how can I make it ? is it possible ?... (3 Replies)
Discussion started by: ust
3 Replies
Login or Register to Ask a Question