Sending Startup Output to File and Console


Contents

About This Document
    Related Documentation
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.

Related Documentation

The AIX and RS/6000 product documentation library is also available:

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


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.)
Sending Startup Output to File and Console: swconsole.boot.325.cmd ITEM: FAX
Dated: 98/09/08~00:00 Category: cmd
This HTML file was generated 99/06/24~12:41:56
Comments or suggestions?
Contact us