Sending Startup Output to File and Console


Contents

About this document
Procedure

About this document

It is often useful to have a record of the messages displayed on the console during boot time. AIX Version 4 comes with the alog command, which provides the ability to log boot messages to more than one file (such as /dev/console and /var/adm/ras/bootlog). If you are using AIX Version 3, you can use the script contained in this document to accomplish this.

This script captures the output from programs and scripts started in the /etc/inittab and sends this output to a file and to the console (or whichever tty you specify). It has been tested on AIX Version 3.2.5.1. Users of AIX Version 4 should use the alog command.


Procedure

WARNING: Before using the script in this document on a production system, test it first. Since this script becomes part of the startup process, you MUST have tested alternate boot media available in case of a problem.

Put the following text in a file called swconsole in /usr/bin.

       #!/usr/bin/ksh
       # swconsole
       /usr/bin/awk -v FILE="$1"  -v OUTPUT="$2" '
       {
       output_file=sprintf("%s",FILE)
       screen_output=sprintf("%s",OUTPUT)
  
       printf("%s\n",$0) >>output_file
       printf("%s\n",$0) >>screen_output
       }' >/dev/null
       # End of /usr/bin/swconsole.
Make the file executable and owned by user and group bin:
       # cd /usr/bin
       # chmod 755 swconsole
       # chown bin:bin swconsole
The syntax for using this script is as follows:
       swconsole /name/of/file /name/of/tty 

For example:

       swconsole /tmp/rc.out /dev/console
Modify the entry in /etc/inittab of each script or program you wish to monitor.

For example, modify the following entry:

       rc:2:wait:/etc/rc > /dev/console 2>&1
       # Multi-User checks.
Change it to:
       rc:2:wait:/etc/rc 2>&1 | swconsole /tmp/rc.out /dev/console
       # Multi-User checks.
In the preceding example, the initialization messages from /etc/rc will be written to both the console and to /tmp/rc.out. (The file /tmp/rc.out can be any writable file of your choice.)


[ Doc Ref: 90605199514600     Publish Date: Spt. 07, 1999     4FAX Ref: 8244 ]