将重启的结果输出到log.txt中
停止数据的方式可以根据实际情况选择 shutdown immediate;可以将该语句加到crontab中实现定时重启
#!/bin/bash
su - oracle <<EOF
echo "$(date +'%Y-%m-%d %H:%M:%S')----open----" >>/log.txt
export ORACLE_HOME=/u01/app/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
sqlplus / as sysdba <<EOF
shutdown abort;
startup;
exit
EOF
echo "restart-ok" >>/log.txt
echo "$(date +'%Y-%m-%d %H:%M:%S')----end----" >>/log.txt