IBM Support

Automated Startup and Shutdown of Custom Software

Question & Answer


Question

Automated Startup and Shutdown of Custom Software

Answer

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 Versions 4 and 5.

Automating startup of custom software
Automating shutdown of custom software
Related documentation

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" 

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.


Related documentation

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

  • AIX 5L Version 5.3, 6.1 or 7.1 System Management Guide: Operating System and Devices
  • AIX 5L Version 5.3, 6.1 or 7.1 Commands Reference, (references for init, inittab, and shutdown)

[{"Product":{"code":"SWG10","label":"AIX"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Process and memory management","Platform":[{"code":"PF002","label":"AIX"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Historical Number

isg1pTechnote0354

Document Information

Modified date:
17 June 2018

UID

isg3T1000220