Monday, February 10, 2020

Linux - Script to check archives on production every 15 mins and copy it on test server

Linux - Script to check archives on production every 15 mins and copy it on test server


*/5 * * * * sh /home/scripts/cp_arch.sh   #### Script will run every 5 mins from crontab

Main script:
=================================================

#!/bin/bash
#cp_arch.sh
#Script to copy archive logs to Test Server

find /u01/archive -mmin -720 > /home/oracle/scripts/find_arch.txt 

### Above will check all the archives generated in last 12 hrs , we can reduce as per environment. #####


tail -n+2 /home/oracle/scripts/find_arch.txt > /home/oracle/scripts/final_lst

while IFS= read -r line; do
    echo "scp $line oracle@test.example.com:/u01/arch_backup_prod/"
done < /home/oracle/scripts/final_lst > /home/oracle/scripts/last_12hr.sh

sh /home/oracle/scripts/last_12hr.sh

###### End of Script

=================================================





Thanks

No comments:

Post a Comment