#!/bin/bash -x
su - oracle -c "sqlplus / as sysdba" <<EOF
column today new_value today_file
select 'jk_'||to_char(sysdate,'yyyymmddhh24mi') as today from dual;
SPOOL /jk/&&today_file..log;
set serveroutput on;
set linesize 1200
@/jk/jk.sql
spool off
exit;
EOF
sleep 20
#assignment
export wj=`ls -lt /jk/ | grep log | head -n 1|awk '{print $9}'`
export kj=`cat $wj |grep "^XXX"|awk '{print $6}'` //过滤出表空间名称
echo $wj
echo $kj
echo "当前XXX表空间已使用$kj%" | mail -s "OA数据库表空间使用" [email protected]
cd /jk
rm -rf *.log
exit
#jk.sql
select a.tablespace_name,a.bytes/1024/1024 "Sum MB",a.maxbytes/1024/1024 "Max MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",
round(((a.bytes-b.bytes)/a.bytes)*100,2) &