Hi,
This script is working successfully when i executed from shell prompt, but the same script scheduled in crontab its not deleting the files,
#! /bin/bash
DAY_1=`(date --date='4 months ago' '+%Y-%m')`
log=/tmp/cleant
adir=/u01/app/oracle/admin/talon/adump
udir=/u01/app/oracle/admin/talon/udump
bdir=/u01/app/oracle/admin/talon/bdump
export DAY_1
echo "Cleaning trace files start " > $log
date >>$log
echo $DAY_1 >>$log
cd $adir
ls -l | grep -i $DAY_1 | awk '{ print $8}'| xargs rm -f
cd $udir
ls -l |grep -i $DAY_1 | awk '{print $8}'| xargs rm -f
cd $bdir
ls -l |grep -i $DAY_1 | awk '{print $8}'| xargs rm -f
cd
echo "Finished " >>$log
i am trying to remove files 4 months ago which would be in huge number(500000 approx. files). if run
$ . remtrc ( it successfully removes files)
crontab (example)
10 00 1 * * * /home/oracle/remtrc > /tmp/cleantrc.log
but from crontab it not able to remove files.
what i am missing in the script.