Shell Type:
>echo $SHELL
/bin/ksh
Cronjob :
15 * * * * /bin/ksh /wls_domains/resMGT/logs/bea/wlr3queuetransaction.sh > /wls_domains/resMGT/logs/bea/data/script.log
The script is as below:
##log files and lookup file "wlr3queue.txt" are in the same path of the script ##/wls_domains/resMGT/logs/bea/wlr3queuetransaction.sh
Script :
#!/bin/ksh
dt=`date +%Y-%m-%d`
xy=`date|awk '{print $4}'|awk -F":" '{print $1}'`
yz=`expr $xy - 1`
if [ $yz -le 9 ]
then
yz=0$yz
fi
if [ $xy -gt 0 ]
then
for i in `cat wlr3queue.txt`
do
sum=0
count=`gzgrep -i "$dt" admin_resMGT_access.log* | grep "$yz:[0-5][0-9]" | grep "$i" | wc -l`
if [ $count -gt 0 ]
then
name=`echo $i | cut -d'/' -f3`
gzgrep -i "$dt" admin_resMGT_access.log* | grep "$yz:[0-5][0-9]" | grep "$i" | awk '{print $8}' > consumed_time.txt
for j in `cat consumed_time.txt`
do
j_ms=`echo "$j * 1000" | bc`
echo $j_ms >> consumed_ms_time.txt
done
for k in `cat consumed_ms_time.txt`
do
sum=`echo "$sum + $k" | bc`
done
avg=`echo "scale=2; ($sum/$count) "| bc`
min=`cat consumed_ms_time.txt | sort -n | head -1`
max=`cat consumed_ms_time.txt | sort -n | tail -1`
else
avg=0
min=0
max=0
fi
(
echo $yz","$count","$avg","$min","$max
)>>/wls_domains/resMGT/logs/bea/data/$name$dt.csv
rm -f consumed_ms_time.txt
done
else
echo "script won't execute at this hour" > temp.txt
fi
I have executed the following commands and the script ran successfully.
./wlr3queuetransaction.sh
sh -x wlr3queuetransaction.sh
/bin/ksh /wls_domains/resMGT/logs/bea/wlr3queuetransaction.sh
/bin/ksh/ wlr3queuetransaction.sh.
How to debug? What to do?
cron
it's almost always an environmental variable that gets lost and that variable is almost always$PATH
. – Bratchley Feb 03 '15 at 21:19