I found the following command:
history | tail -20 | mail -s "log `hostname` pada `date`" mailid[at]corporate.com
I want to combine it with an automatic logout script: The system should send an email alert when the root user has logged out from SSH/terminal. The mail should have the date and include the output of the aforementioned command.
sudosh
and give nobody the root password -- only allowsudo sudosh
. Make sure to contact your legal department before you do this though.