Wednesday, July 27, 2016

Auto logs zip script for Linux

Auto logs zip script for Linux 


vim  /root/scripts/zip_alllogs.sh

#!/bin/sh

find /mnt/logs/apilogs -type f -name "*.txt" -mtime +2 > /tmp/apilogs.txt

for i in `cat /tmp/apilogs.txt`;

do bzip2 $i;

done

#############################

#!/bin/sh

find /mnt/logs/httplogs -type f -name "*.txt" -mtime +2 > /tmp/httplogs.txt

for i in `cat /tmp/httplogs.txt`;

do bzip2 $i;


done

########################################################################

add to cron job

00 01 * * * /bin/bash /root/scripts/zip_alllogs.sh

########################################################################




No comments:

Post a Comment