切换到ORACLE执行SH的脚本
root@tha11db1:~# crontab -l
#ident "%Z%%M% %I% %E% SMI"
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# The root crontab should be used to perform accounting data collection.
01 1 * * * su - oracle "/u01/backup/scripts/monscript.sh"
编写SH文件
/u01/scripts/script.rcv >/u01/scripts/script.log
.rcv文件
echo '/u01/app/oracle/diag/rdbms/*/trace/alert_*.log
'
tail -500 /u01/app/oracle/diag/rdbms/*/trace/alert_*.log
echo '
'
echo '集群警告文件crsd.log '
echo '==============================================================='
echo '/u01/app/crs_home/log/*/crsd/crsd.log'
tail -100 /u01/app/crs_home/log/*/crsd/crsd.log
sqlplus -s /nolog<<EOF
conn / as sysdba
@script.sql
exit
EOF
编写查询.SQL,这里就根据需要执行的语句自行编写就好了。
oracle@tha11db1:/u01/scripts$ more script.sql
host echo '
'
host echo '数据库状态'
host echo 'select name,log_mode,open_mode from v$database;'
select name,log_mode,open_mode from v$database;
host echo '
'
host echo '数据库登陆记录数量trial_login'
host echo 'select count(0) from trial_login;'
select count(0) from trial_login;
host echo '
'