Cron issue

i have written a script to sftp yesterday's logs from another server as below:

cd /export/home/abc/xyz/tt

d=`gdate -d'yesterday' +%Y%m%d`     

sftp abc@XXX.XX.XX.XX<<EOF
cd /yyy/logs/archive
mget abc.log.$d*
EOF

cd /export/home/abc/xyz/scripts
nohup ./ss.sh PROD &

it is working fine when ran as:

sh ./scriptname.sh

but when i cronned it , it is pulling logs from the starting date of logs that the folder contains.

ex; today is 15th April 2014 , so the script should pull 14th April 2014 logs
It is working fine when i ran it as sh ./scriptname.sh
but when i cronned it , it is pulling log files which has starting date of 1st january 2014 which is the minimum date that the folder contains

is there any changes need to be done for the script to cron it..

Pls check the cron logs sent to the mail of the user running the cron.

I think you cron is not able to find the path of gdate and as a result '$d' will be a null string and the subsequent mget will become

mget abc.log.*
1 Like

Hi rajamadhavan

Yes you are right
it is not working because it is unable to fidn teh path for gdate
i changed it to /usr/local/bin/gdate
and it worked fine

Thanks for your suggestion