Table of Contents
AIX RC.Scripts
Summary: ALthough AIX is by now on version 7.3 I find these old pages so fascinating I decided to keep them. On this page I'll show you how to configure rc scripts on AIX. I'll even show you an example script. This page is for AIX 5.3 and AIX 6.1.
Date: Between 2010-2013
Refactor: 21 December 2024: Checked formatting.
Introduction
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:
- 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.
- 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).
- 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).