Below line of my bash script not write output of /tmp/DPE_SC/LoadUnits/ttx/bin/deasn9 -b -a cdrr6 $fnames
to file $dst_dir"/"$fstat"-"$fnames".txt
when I execute from crontab.
It only creates empty file named $dst_dir"/"$fstat"-"$fnames".txt
Sure it works properly from command line manually.
/tmp/DPE_SC/LoadUnits/ttx/bin/deasn9 -b -a cdrr6 $fnames > $dst_dir/$fstat-$fnames.txt
What is my mistake?
This is my whole script
#!/bin/bash
export PATH=/tmp/DPE_SC/LoadUnits/ttx/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/tmp/DPE_SC/Tools:/usr/X11R6/bin
src_dir=/charging/chsLog/ready
dst_dir=/Core/cdr
cd $src_dir
lastfile=
cat $dst_dir/last_cdr.txt
filenames=
ls -t | grep ^chsLog
fcounter=1
for fnames in $filenames
do fstat=`stat -c %y ${fnames} | cut -d '.' -f1` fstat=`echo ${fstat//[^0-9]/}` if [[ $fstat -gt $lastfile ]] then if [[ $fcounter -eq 1 ]] then echo $fstat > $dst_dir/last_cdr.txt let "fcounter = $fcounter + 1" fi deasn9 -b -a cdrr6 ${fnames} > $dst_dir/$fstat-${fnames}.txt fi done
deasn9 -b -a cdrr6 ${fnames} > $dst_dir/$fstat-${fnames}.txt
line not work from crontab. I sees that lineecho $fstat > $dst_dir/last_cdr.txt
worked well from crontab. – tsoomo