Periodic cleanup script for 3 partitions a month for the partition table

1. Timed task -- the current date of the month before the current month

05 20 1  * *  /bin/sh  /home/oracle/truncate_partition.sh &> /dev/null
05 20 11 * *  /bin/sh  /home/oracle/truncate_partition.sh &> /dev/null
05 20 21 * *  /bin/sh  /home/oracle/truncate_partition.sh &> /dev/null

[oracle@testglt]$ cat /home/oracle/truncate_partition.sh
#!/bin/bash

source /home/oracle/.bash_profile
sqlplus -s test/test@db>> /home/oracle//truncate_partition.log <<EOF
set feedback off heading off term off
set pages 1000 trim on trims on lines 32767 long 999999
set echo off
spool /home/oracle/truncate_partition_`date +%y%m%d`.sql
@/home/oracle//truncate_partition.sql
spool off
EOF

sqlplus sys/test@dbas sysdba  >> /home/oracle/exec_truncate_p.log <<EOF
@/home/oracle/truncate_partition_`date +%y%m%d`.sql
EOF

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324883910&siteId=291194637