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

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
Gunnar02
  • 1
  • 1

1 Answers1

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

Aleksandar Ivanisevic
  • 3,327
  • 19
  • 24