Automated Startup and Shutdown of Custom Software


Contents

About this document
    Related documentation
Automating startup of custom software
Automating shutdown of custom software
Recommended fixes

About this document

This document discusses how to customize the system so that user defined applications are automatically started during system boot and halted during system shutdown.

Information in this document is applicable to AIX Version 4.x.

Related documentation

For more in-depth coverage of this subject, the following IBM publications are recommended:

The product documentation library is also available at the following link:
http://www.rs6000.ibm.com/resource/aix_resource/Pubs/index.html


Automating startup of custom software

During bootup, the init process sequentially scans the /etc/inittab file to determine what actions to take during boot.

If applications, daemons, or other user actions need to be included during the system boot process, an entry for each should be added to the /etc/inittab file.

The usual implementation is to create a script called rc.local and have all user applications started within this script. This script can be called from a suitable location within the /etc/inittab file, usually after all system applications and services have started, but before any user logins are enabled. This is usually just before the console login entry.

NOTE: IBM supplied startup scripts should NOT be modified to include any additional startup commands. Such modifications could be lost during software upgrades and could lead to unexpected boot problems.

Following is an example:

    rclocal:2:wait:/etc/rc.local > /dev/console 2>&1 

In the above entry, init will wait for this script to complete before processing the remaining entries. For this reason, it is important that this script completes and does not run forever. If any daemons are being started, they should behave as proper UNIX daemons.

If the daemon, application, or command needs to be run as a certain user, then the su command can be included to run the command.

For example:

    su myuser "-c /usr/bin/myapp" 

It is recommended that the script contains a start and end output statement at a minimum. The output should be long enough to enable troubleshooting any errors that may occur during a standard system boot.

For example:

    #!/bin/ksh 
    echo "Starting User Applications...." 
    echo "Starting Application XYZ" 
    su myuser "-c /usr/bin/myapp" 
    echo "Startup of User Applications completed" 

The application resource definitions that are used for user generated processes do not hold for processes generated by init. This mainly refers to the resources that are specified in /etc/security/limits. If a user-supplied application requires certain resources and will be started by init, the application should insure these limits are set sufficiently, or they may be set within the startup script.

Following is a example of what the commands look like in init:

    ulimit -m unlimited 
    ulimit -s unlimited 
    ulimit -d unlimited 

Automating shutdown of custom software

The shutdown command is used to cleanly bring down an AIX system and reboot if necessary. During its operation, it will bring down all necessary AIX subsystems and file systems.

If a shutdown script called /etc/rc.shutdown exists, the system will execute these commands first. This is where any custom commands to bring down any user-supplied applications should be implemented. It is recommended that the script contain a start and end output statement at a minimum. The output should be long enough to enable troubleshooting any errors that may occur during a standard system shutdown. An example follows:

    #!/bin/ksh 
    echo "Stopping User Applications...." 
    echo "Stopping Application XYZ" 
    [ commands to stop application ] 
    echo "Shutdown of User Applications completed" 
NOTE: If you are running AIX 4.2, you must be at maintenance level 4.2.1 for /etc/rc.shutdown to be recognized by the shutdown command.

In addition, shutdown checks the error status of the /etc/rc.shutdown script, so if an error occurs shutting down the user applications, the shutdown process will halt without completing the shutdown. The user can then troubleshoot any shutdown issues with the custom software. It is up to the supplier of the /etc/rc.shutdown script to insure an error condition is returned.


Recommended fixes

    APAR       Description                               AIX Level
    ----       -----------                               ---------
    IX65326    ADD /ETC/RC.SHUTDOWN TO SHUTDOWN SCRIPT   4.1



[ Doc Ref: 90605200714622     Publish Date: Spt. 28, 2000     4FAX Ref: 9087 ]