crontab定时任务

创建一个定时任务,用于删除一天前的归档日志。用oracle用户创建的,收到报错邮件

/home/oracle/del_arc.sh: line 4: rman: command not found

找不到命令,那是环境变量的问题,加入了ORACLE_HOME和ORACLE_HOME,还是报错

Message file RMAN<lang>.msb not found

Verify that ORACLE_HOME is set properly

改成source  .bash_profile后正常。

$ cat del_arc.sh
#!/bin/bash
#export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1/
#export ORACLE_SID=SCPRD
source .bash_profile
rman target / nocatalog log /home/oracle/delete_arch.log <<EOF
run
{
allocate channel c1 type disk;
delete noprompt archivelog all completed before 'sysdate-1';
release channel c1;
}
EOF

原文地址:https://www.cnblogs.com/historynote/p/13825611.html