High Availbility

OS & Virtualization

Friday, June 15, 2007

Automatic Startup Scripts on Linux

Automatic Startup Scripts on Linux

Create a file in the /etc/init.d/ directory, in this case the file is called myservice, containing the commands you wish to run at startup and/or shutdown.

Use the chmod command to set the privileges to 750:
chmod 750 /etc/init.d/dbora

Link the file into the appropriate run-level script directories:
ln -s /etc/init.d/myservice /etc/rc0.d/K10dbora
ln -s /etc/init.d/myservice /etc/rc3.d/S99dbora


Associate the myservice service with the appropriate run levels:
chkconfig --level 345 dbora on

The script should now be automatically run at startup and shutdown (with "start" or "stop" as a commandline parameter) like other service initialization scripts.

Method 2

Create a script at /usr/local/bin with the following information (eg dbora)

/home/oracle/Orahome1/bin/lsnrctl start
sqlplus /nolog << EOF
conn / as sysdba;
startup;
exit;
EOF


Add the following lines into /etc/rc.d/rc.local
su - oracle -c "/usr/local/bin/startdb"

No comments: