Capture of all commands issued by the user “root”

I have to write a script (not C based) that allows to capture of all commands issued by the user �root�.

First, I tried to monitor the .bash_history but the commands are written in chunk after the .bash_history is closed.

How can I capture the commands in Real-Time without waiting root to close his shell ?

It helps to mention what operating system you are talking about, also why does it need to be a shell script?

It has to be compliant with RHEL3, RHEL4, SLES9, AIX 5.2, AIX 5.3

the module has to be written as a script because it has to be integrated in a proprietary agent that runs only scripts.

All the processing has to run in the background (Not a GUI).

man script

Add the following line to .profile (In case you are using Ksh)

script -a ~/.termlog`date +%m%d%y`

This enable to capture all the terminal activities to a file.

Please let me know if this works.

Thanks
Nagarajan Ganesan