-
https://cron.help/every-2-weeks
-
https://crontab.guru/examples.html
-
在crontab -e 下:
-
0 0 Fri [ $(expr $(date +%W) % 2) -eq 1 ] && /home/oracle/gather_stats_table.sh > /home/oracle/gather_stats.log
-
在/oracle/home 下 vi gather_stats_table.sh
-
输入‘#!/bin/bash
-
export ORACLE_SID=cdbname
-
export ORACLE_BASE=/u01/app/oracle/product/11.2.0.4/dbhome_1
-
export ORACLE_HOME=/u01/app/oracle
-
export PATH=$ORACLE_HOME/bin:$PATH
e```sql
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
sqlplus / as sysdba <<EOF
alter session set container=xxxx
EXEC DBMS_STATS.gather_table_stats('SCOTT', 'EMP');
EOF
if ["$?" -ne 0 ]
then
echo "sqlplus error!"
exit 2
else
ecjp "gather stats success!"
exit 0
fi
然后在Oracle home下:
chmod u+x gather_stats_table.sh
`
最后于 2021-4-20
被????编辑
,原因: