This KB Article described how to Configure a cron job to run daily to delete all archived logs older than 60 days On Log Forwarder nodes.
STEP:1 Create a file tar-del.sh in /opt/versa/scripts/van-scripts/ directory as a root user and edit.
sudo vi tar-del.sh
Copy and paste the below script in vi tar-del.sh
#!/bin/bash
startday=$1
endday=$2
tmp1="/tmp/tmp_$.txt"
for tenant in /var/tmp/archive/tenant-*; do
echo $tenant
for vsn in $tenant/VSN0-*; do
echo $vs
cd $vsn
for i in `seq $startday $endday`
do
date_point=`date +%Y%m%d -d "$i days ago"`
echo $date_point
echo "Deleting files from $tenant $vsn for date $date_point" >> $tmp1
# find . -name "$date_point.*.gz" -print >> $tmp1
# to delete
find . -name "$date_point.*.gz" -type f -delete
done
done
done
# comment this out later
exit
rm -rf $tmp1
then save using Esc :wq!
STEP:2 Give all the permissions to tar-del.sh
STEP:3 Create archive-delete file in /tmp directory and edit as a root user.
sudo vi archive-delete
Copy and paste the below script in vi archive-delete
0 0 * * * root /opt/versa/scripts/van-scripts/tar-del.sh 60 365 >> /var/log/versa/tar-del.log
then save using Esc :wq!
STEP:4 Give the below permissions to archive-delete file.
STEP:5 Move the archive-delete in /etc/cron.d directory.
mv archive-delete /etc/cron.d/
********************END OF DOCUMENT********************