[root@localhost ~]# vim /etc/init.d/oracle #!/bin/bash #chkconfig:345 61 61 #description:Apache # # Set ORA_HOME to be equivalent to the $ORACLE_HOME # from which you wish to execute dbstart and dbshut; # # Set ORA_OWNER to the user id of the owner of the # Oracle database in ORA_HOME. ORA_HOME=/opt/oracle/product/19c/dbhome_1 ORA_OWNER=oracle if [ ! -f $ORA_HOME/bin/dbstart ] then echo "Oracle startup: cannot start" exit fi case "$1" in 'start') # Start the Oracle databases: echo "Starting Oracle Databases ... " echo "-------------------------------------------------" date +" %T %a %D : Starting Oracle Databases as part of system up." echo "-------------------------------------------------" su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" echo "Done" # Start the Listener: echo "Starting Oracle Listeners ... " echo "-------------------------------------------------" date +" %T %a %D : Starting Oracle Listeners as part of system up." echo "-------------------------------------------------" su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" echo "Done." echo "-------------------------------------------------" date +" %T %a %D : Finished." echo "-------------------------------------------------" touch /var/lock/subsys/oracle ;; 'stop') # Stop the Oracle Listener: echo "Stoping Oracle Listeners ... " echo "-------------------------------------------------" date +" %T %a %D : Stoping Oracle Listener as part of system down." echo "-------------------------------------------------" su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" echo "Done." rm -f /var/lock/subsys/oracle # Stop the Oracle Database: echo "Stoping Oracle Databases ... " echo "-------------------------------------------------" date +" %T %a %D : Stoping Oracle Databases as part of system down." echo "-------------------------------------------------" su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" echo "Done." echo "" echo "-------------------------------------------------" date +" %T %a %D : Finished." echo "-------------------------------------------------" ;; 'restart') $0 stop $0 start ;; esac