[CentOS] Bash script to logout user from console

Jeff Larsen jlar310 at gmail.com
Fri Apr 25 08:06:41 UTC 2008


On Thu, Apr 24, 2008 at 11:48 PM, Joseph L. Casale
<jcasale at activenetwerx.com> wrote:
> I am stumped to figure out how to logout a user after they run a script
> interactively when logged into the console. I see how to do it if in x, but
> this server does not have x installed.

There are 2 possible interpretations to your post.

1. You want the last action of the script being run by the user on the
console to log out the user. In this case make the last command of the
shell script

kill -HUP `pgrep -s 0 -o`

This kills the login shell.

2. The user neglects to log out and you as root wish to force a logoff
without having to go to the console. The console session will have a
parent process that shows as "login -- <username>" in a ps -ef output.
Kill that process.

-- 
Jeff



More information about the CentOS mailing list