Login-Logout Detection + MYSQL
Hello all, I need to detect when a user has logged in/out into solaris 10, once the user has logged/unlogged I need to execute a MYSQL command, I was thinking on the /etc/.login file to execute a bash command that calls to mysql, but I just can not find how to execute something on the logout.
Somebody can help me?
Thanks in advance!
# 3
You can try the trap command as follows:
trap <command> 0
Put this in /etc/profile or users .profile and it should run <command> when the user exits the shell. You need to look at handling control-C (also with trap) and such to make sure the user cannot bypass the logout procedure.
Also you would need to check if the user has entered a shell by typing sh or exec sh.
# 6
I'd do it with auditing/bsm, as its very easy for users to bypass a .bash_logout or similar. Besides the .bash_logout wouldn't be executed if a user runs, for example:ssh <host> <command> .7/M.