SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


Sidebar

Recently Changed Pages:

View All Pages


View All Tags


LinkedIn




WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you.
Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer.


Pages with comments

View All Comments

aixrcscripts

AIX RC.Scripts

Although I thought RC scripts were pretty simple I ran into some scripts yesterday that were so not rc.scripts, but configured for them anyway. The point was, they didn't had an start/stop parameter defined…

So, how do rc.scripts work:

  1. Write a single script, put it into /etc/rc.d/init.d, make sure the script accepts a single parameter of start or stop and does the right thing.
  2. In /etc/rc.d/rc2.d create a link (ln -s) to the script in init.d called Sxxname where xx is a number that dictates where in comparison to other scripts in the directory your script will execute (lower number first).
  3. In /etc/rc.d/rc2.d create a link to the script in init.d called Kxxname where xx is a number which dictates when the script is run to stop your app in comparison to other scripts in the directory (lower number first).

Example Script

This is an example script on how a rc.script might look:

#!/bin/ksh
# Created by Sjoerd Hooft
# Added on 5 November 2010
 
### Script Variables
APPDIR=/opt/sft/product/bin
APPNAME=product
RUN_USER=appuser
 
export JAVA_HOME=/usr/java5_64
 
case "$1" in
 
start )
   echo "Starting the ${APPNAME} Application"
   su $RUN_USER -c ${APPDIR}/startup.sh
;;
 
stop )
   echo "stopping the ${APPNAME} Application"
   su $RUN_USER -c ${APPDIR}/shutdown.sh
;;
 
* )
   echo "Usage: $0 COMMAND"
   echo "---------------------------"
   echo "start    - Start ${APPNAME} instance in ${APPDIR}"
   echo "stop     - Stop ${APPNAME} instance in ${APPDIR}"
   echo
   exit 1
 
esac

Example Creating Symbolic Links

This is an example on creating symbolic links for automatic startup for oracle. Oracle should start first (meaning a low Sxx) and stop last (meaning a high Kxx):

sjoerd@db:/etc/rc.d/rc2.d>sudo ln -s /etc/rc.oracle S10oracle
sjoerd@db:/etc/rc.d/rc2.d>sudo ln -s /etc/rc.oracle K90oracle

Extra Resources

What does RC mean:

Runtime Commands:
From the original Jargon File: http://www.catb.org/jargon/oldversions/jarg310.txt:

:rc file: /R-C fi:l/ n. [UNIX: from `runcom files' on the {CTSS} system ca.1955, via the startup script= `/etc/rc'] Script file containing startup instructions for an application program (or an entire operating system), usually a text file containing commands of the sort that might have been invoked manually once the system was running but are to be executed automatically each time the system starts up. See also {dotfile}, {profile} (sense 1).
You could leave a comment if you were logged in.
aixrcscripts.txt · Last modified: 2021/09/24 00:24 (external edit)