Startup and shutdown script

Hi all,

I'm writing a script to stop & start oracle:

su - oracle -c "sqlplus / as sysdba" -c "shutdown immediate">> ${log} 2>&1

The {log} refers to the log file. The part in bold gives error:

/usr/sbin/shutdown:  Only root can run /usr/sbin/shutdown

Pls suggest how to correct this.

regards.

You are running the shutdown in shell context i.e. trying to shutdown the system!
Try to nest two types of quotes

su - oracle -c "sqlplus / as sysdba -c 'shutdown immediate' " >> ${log} 2>&1

Hi,

I tried your suggestion but still doesn't work.

regards

B Component Startup and Shutdown Scripts

:wall:

1 Like

According to the article this should work

su - oracle -c "echo 'shutdown immediate' | sqlplus '/ as sysdba' " >> ${log} 2>&1

If sqlplus takes -c instead of stdin, this should work, too

su - oracle -c "sqlplus '/ as sysdba' -c 'shutdown immediate' " >> ${log} 2>&1

Hi all,

Thanks for your help.

Below has worked for me:

su - oracle -c "echo 'shutdown immediate' | sqlplus '/ as sysdba' " >> ${log} 2>&1

The 2nd one didn't work but ok 1st one has worked.

Thanks & regards.