# Way to automagically log a session when logging in?

## Thiemo

Hi all,

is there a way to log everything a user does after he has logged in automagically? I think of something like 'script session_$(date +'%Y%m%dT%H%m%S').log', however I am not sure whether this can be used as 'login shell'.

Cheers

Thiemo

----------

## geki

I would try a shell wrapper for 'script session_$(date +'%Y%m%dT%H%m%S').log' like

 *Quote:*   

> #!/bin/bash
> 
> # log shell session
> 
> script session_$(date +'%Y%m%dT%H%m%S').log

 or the alternative of a C wrapper.

----------

## Thiemo

And then put the wrapper as login shell in /etc/passwd? Might work, but it looks quite aweful to me. I mean, is this not a feature the big players like AIX, Solaris should have standardized for there high profile production system...

I just forgot to see whether bash or zsh can do the logging right away (not only the history stuff)!

 *geki wrote:*   

> I would try a shell wrapper for 'script session_$(date +'%Y%m%dT%H%m%S').log' like
> 
>  *Quote:*   #!/bin/bash
> 
> # log shell session
> ...

 

----------

## Thiemo

I put a call of script into .zshrc checking if the log file variable at the beginning was already set and if not, setting it. This prevents inifinite recursion.

Caveat of this solution is that sftp sessions do not get logged.

 *Thiemo wrote:*   

> And then put the wrapper as login shell in /etc/passwd? Might work, but it looks quite aweful to me. I mean, is this not a feature the big players like AIX, Solaris should have standardized for there high profile production system...
> 
> I just forgot to see whether bash or zsh can do the logging right away (not only the history stuff)!
> 
>  *geki wrote:*   I would try a shell wrapper for 'script session_$(date +'%Y%m%dT%H%m%S').log' like
> ...

 

----------

