Reputation: 351
.ssh/rc can execute script when user logged in.
But when user logged out with ssh, how it execute script?
Upvotes: 0
Views: 128
Reputation: 171
You can add a trap to execute your script when the user logs out:
trap 'bash /path/to/yourscript.sh; exit' 0
If the shell is bash then any code you put in the ~/.bash_logout
file will be executed on logout. For csh, the file is .logout.
Another option would be to run a daemon like this:
setsid mydaemon.sh >/dev/null 2>&1 < /dev/null &
Which can execute your script at any time after the user has logged out.
Upvotes: 1