现象:在oracle用户下,不执行crontab
分析:
(1)查看crontab -l */5 * * * * /bin/bash /home/oracle/tablespace_check.sh
(2)查看服务service crontab status
[oracle@YCZBNCPOAP ~]$ service crond status crond (pid 37063) 正在运行...
(3)执行文件
[oracle@YCZBNCPOAP ~]$ /bin/bash /home/oracle/tablespace_check.sh [oracle@YCZBNCPOAP ~]$
结果:
PS:总结crontab任务不执行可以从这些方面入手
1:请确保手工可以执行该文件(给sh文件增加X权限,看文件格式是否为unix→ set ff? →set ff=unix)
2:确认开始crond服务(service crond status/start/stop)
3: 确认给sh文件制定bash环境
if [ -f ~/.bash_profile ];
then
. ~/.bash_profile
fi
#!/bin/bash
# tablespace usagep check
#source ~/.bash_profile
if [ -f ~/.bash_profile ];
then
. ~/.bash_profile
fi
function check {
sqlplus -S "/ as sysdba" << EOF
set linesize 200
set pagesize 200
spool /tmp/tablespace.log
select a.tablespace_name, maxtotal as total, (maxtotal-total+free)as free,(total-free) as usage from
(select tablespace_name, sum(bytes)/1024/1024 as total,sum(maxbytes)/1024/1024 as maxtotal from dba_data_files group by tablespace_name) a,
(select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b
where a.tablespace_name = b.tablespace_name;
spool off
set linesize 100
set pagesize 100
spool /tmp/autex.log
select tablespace_name,autoextensible from dba_data_files;
spool off
quit
EOF
};check &>/dev/null
文章评论