0
PFB script
dd=$(perl -e 'use POSIX;print strftime "%Y%m%d",localtime time-172800;')

Date=$(perl -e 'use POSIX;print strftime "%d%m%Y",localtime time-172800;')

for i in `cat /path/Path_CDR.txt`
do
cd $i
compress event*$dd*.asn
compress event*$dd*.CDR
zcat event*$dd* |grep Event |awk -F "," '{print $14,$16}'|awk -F '"' '{print $2","$4","'$Date'}' >>/path/abc$Date.txt

done

Output1: Script run manually using sh -x (script name) output comes in as per below format(Coorect)

07923243305,14,4112019
07923241717,44,4112019
07923224727,33,4112019
07923241717,10,4112019

while schedule on crontab the output comes in below format only date format issue(date issue 4.11202e+06)

07923243305,14,4.11202e+06
07923241717,44,4.11202e+06
07923224727,33,4.11202e+06
07923241717,10,4.11202e+06

Kindly help me with this

0

most likely your locale variables are not in cron environment.

check the values of LANG* and LC_* in your shell env and set them explicitly at the beginning of your script, e.g. I have

[alex@alex ~]$ set | grep ^LANG
LANG=en_US.UTF-8
[alex@alex ~]$ set | grep ^LC_

so I would put an

export LANG=en_US.UTF-8

at the beginnning of the script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.