質問

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
役に立ちましたか?

解決 2

I found what I mistaken. cdrr6 was not only option. It is cdr formatting library. Then I exported LIB path from scipt. Now it worked perfectly.

他のヒント

Remember that your .profile, .bashrc, et. al. are not available from inside cron.

Environment variables have to be defined directly in the crontab.

e.g.

fstat=myValue
fname=aName
@hourly myJob ${fstat} ${fname}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top