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:

IBM documentation can also be found online at the following url:

http://www.rs6000.ibm.com/resource


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 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 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 process 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 

Automated Startup and Shutdown of Custom Software: autostart.custom.sw.4x.cmd ITEM: FAX
Dated: 99/04/24~00:00 Category: cmd
This HTML file was generated 99/06/24~12:41:57
Comments or suggestions?
Contact us