Particular script not running through crontab


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Particular script not running through crontab
# 1  
Old 06-28-2011
Particular script not running through crontab

Hi,
I have created the below script,
Code:
set -x
# Set the Path of Environment file
ENV_FILE_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/bin
LOG_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/log
export ENV_FILE_DIR
export LOG_DIR
# Set Audit Environment
. ${ENV_FILE_DIR}/QDM.env
export LOGFILE=${LOG_DIR}/obj_`date +%Y%m%d`.log
:>${LOGFILE}
SVRNM=${QDM_CFG_DIR}/svrnames.dat
MAILING_LIST= xxxxxxxx@something.com
for line in $(</opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/cfg/svrnames.dat);
do
echo $line | read servername
export name=$servername
ssh ly228m@$name "ksh /export/home/ly228m/QDM_QA/bin/OBE_schedule.ksh" >> ${LOGFILE}
RC=$?
if [[ ${RC} -ne 0 ]] then
echo "\n ERROR- Executing the object script on $servername \n"
mailx -s "OBJECT SCRIPT FAILURE on $name" $MAILING_LIST
else
mailx -s "OBJECT SCRIPT SUCCESS $name" ${MAILING_LIST}
fi
done < $SVRNM
for line in $(</opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/cfg/svrnames1.dat);
do
echo $line | read servername
export name=$servername
ssh ly228m@$name "ksh /home/ly228m/QDM_QA/bin/OBE_schedule.ksh" >> ${LOGFILE}
RC=$?
if [[ ${RC} -ne 0 ]] then
echo "\n ERROR- Executing the object script on $servername \n"
mailx -s "OBJECT SCRIPT FAILURE on $name" $MAILING_LIST
else
mailx -s "OBJECT SCRIPT SUCCESS $name" ${MAILING_LIST}
fi
done < $SVRNM
exit

which will connect and run another script on 15 servers and get the flat files genrated and transferred. It works perfectly when run manually, however it does not work when scheduled to run through crontab.
Code:
30 00 * * * ksh /opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/bin/new_both.ksh

Please help me out with this issue.
Note: the most weird thign about this there are n number of scripts which are scheduled and works perfectly except for this script Smilie

Last edited by pludi; 06-28-2011 at 04:02 AM..
# 2  
Old 06-28-2011
what you logfile says ?

post your code in [code] tag. (easy for read)
# 3  
Old 06-28-2011
hi itkamaraj,
thanks for the info on the code tag. The script jus does not work as such. There are no files created Smilie
# 4  
Old 06-28-2011
check the cron logs

Code:
 
/var/log/cron*

# 5  
Old 06-28-2011
there is nothing like that as well Smilie
# 6  
Old 06-28-2011
what is the use of this line (it is wrong) ?

Code:
 
for line in $(</opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/cfg/svrnames.dat);
do
...
...
 
done < $SVRNM
 
replace the loop by while
 
while read line
do 
...
...
..
done < $SVRNM

replace these two lines by one line

Code:
 
  echo $line | read servername
  export name=$servername
to
name=$line

replace another for loop also.

Did u set the correct time and format (in the cron entry) and checked the execution ?

just redirect the output to tmp file and see

Code:
30 00 * * * ksh /opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/bin/new_both.ksh 1>/tmp/otuput 2>&1


Last edited by itkamaraj; 06-28-2011 at 04:27 AM..
# 7  
Old 06-28-2011
Hi,
I actually think we are deviating from the real issue. The issue is not with how the script is running rather it is with why it is not running only on crontab Smilie
I have tried the while loop, and preferred the for loop as it uses ssh to connect to a remote server, runs a script an generate files that has to be back on the remote server.
It has to repeat this like for 15 servers, the servers have varied root directory path, based on the root directory path on the servers i have two list files.

---------- Post updated at 02:55 PM ---------- Previous update was at 02:54 PM ----------

I am just inquisitive, does the ssh play a part with the crontab??
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

CRONTAB - one python script is not running

Hi! I'm using a RaspberryPi with standard Raspbian. Currently I'm working on some sort of weather station. For now I have three python scripts - one which is updating txt files for website - update1m.py ( it will not be necessary in few next days so I'll delete it) , second one for updating... (4 Replies)
Discussion started by: bartocham
4 Replies

2. Solaris

Script problem when running on crontab

Hi guys! I created a backup script that works fine when I run manually, but when I put a crontab job to execute it the result are not the expected. (not a time problem). Here is my script: bash-3.00# cat /bk_tool/backup2.sh #!/usr/bin/csh clear set DIR_HOST='SCP08' ... (3 Replies)
Discussion started by: andredemartini
3 Replies

3. Shell Programming and Scripting

Delay in running script from crontab

I am facing an issue where sometimes crontab is running script with some delay. Below is the stmt in script and it is the only stmt in script. echo "running at `date` " >> CRONCHECK.log Below is the cron entry. 0 11 * * * CRONCHECK.sh Below is the time of run each day. running at Fri... (8 Replies)
Discussion started by: Nishant Singh
8 Replies

4. UNIX for Dummies Questions & Answers

crontab not running script

Hi All, I am having the below script to be run from crontab, it it doesnt run. 1 * * * * /home/cobr_ext/test.sh > /home/cobr_ext/temp.txt when i run i manally it runs without any issues. Could please help me as to why doesnt it run the script.:( (7 Replies)
Discussion started by: abhi_123
7 Replies

5. Shell Programming and Scripting

Crontab not running a script

Hi, I posted this in the Solaris forum but I think this one would be more appropriate. I created a script starting with the following lines: #!/usr/bin/ksh flag=n export flag typeset -i quant=0 (...) When running it I'm getting the following 2 errors: /tmp/tstscript/testfail.ksh:... (9 Replies)
Discussion started by: Cvg
9 Replies

6. Shell Programming and Scripting

Problem with crontab running a script

I am trying to use the CRON utility in Fedora 11 & CentOS... I intend to run a script which pops up a warning message every hour and i made the following entry using "CRONTAB -e " * * * * * sh /bin/myscript.sh But this does not seem to be running. Another thing to note is that,... (4 Replies)
Discussion started by: Vabiosis
4 Replies

7. Red Hat

Problems with script running with crontab

Hi, I'm trying the backup a few information commands of my Check Point FW (it's on a SPLAT linux machine). This is the script I wrote: #!/bin/bash cd /var/tmp/ file1=netstat_`/bin/date +%d%m%y`.txt file2=ifconfig_`/bin/date +%d%m%y`.txt file3=cpstatos_`/bin/date +%d%m%y`.txt... (2 Replies)
Discussion started by: nirsh
2 Replies

8. UNIX for Dummies Questions & Answers

Getting error when running script through crontab

Hi all, I wrote small script for Solaris and when I am running it through command prompt its ok, but when I trying to run it using crontab, i am getting error like: ld.so.1: dbloader: fatal: libACE.so: open failed: No such file or directory /tmp/file.sh: line 5: 8304 Killed ... (4 Replies)
Discussion started by: nypreH
4 Replies

9. Shell Programming and Scripting

issue with running script with crontab

I am facing a strange issue while running a script(eg A) from the crontab entry the script calls one more script(eg B) within it now when i run the script A manually(with nohup) it also executes the script B (embedded inside it) as expected. but when i run the script A from the crontab entry... (7 Replies)
Discussion started by: mad_man12
7 Replies

10. UNIX for Dummies Questions & Answers

A command in a script not running in Crontab.

Hi, I made this script for TRU Unix 5.1 OS based Node. When the script was run manually all the commands were running properly. But when it was run from Crontab, one command is not running. This command is not running when the script is running from Crontab: #... (2 Replies)
Discussion started by: mystition
2 Replies
Login or Register to Ask a Question