[RHCE] Automatically. Logging off users after n secondsin unix
m/c.
sholton at mindspring.com
sholton at mindspring.com
Fri Jan 23 10:47:00 EST 2004
What about an 'at' job as a part of /etc/bashrc
-----Original Message-----
From: Jon Carnes <jonc at nc.rr.com>
Sent: Jan 23, 2004 10:10 AM
To: Red Hat Certified Engineer exam study group <rhce at trilug.org>
Cc: Murtuza Topiwala <muza_buddy at hotmail.com>,
MUM-LUG-LIST <linuxers at mm.ilug-bom.org.in>,
LUG-RED-Pete Nesbitt <pete at linux1.ca>,
Shakir Kapadia <shakirk at rediffmail.com>
Subject: Re: [RHCE] Automatically. Logging off users after n secondsin unix m/c.
On Fri, 2004-01-23 at 06:28, Sampat Dharmesh wrote:
> Hi Friends,
>
> I have a small querry, I want to logoff a user after N sec. of login.
> irrespective of the activity he performs.I found of similar option
> TMOUT but that's specific to user's Inactivity incase user is active
> he wont get logged off.Due provide a solution if any one knows.
>
> Regards,
> -Sampat.
>
I don't know of any utility that does this, but if your users are
running the bash shell you could always create a file like so:
vi /usr/local/sbin/autologout
# Automatically log off user after 600 seconds
sleep 540; echo "Auto logout proceeding in 60seconds"
sleep 60; kill -9 $PPID
chmod a+x /usr/local/sbin/autologout
In bash (on Red Hat Linux and probably other OS's as well) the PPID
variable contains the startup shells Process ID Number. Killing that
process logs the user out.
To have it auto-magically work for a user but the following line in at
the bottom of the their .bashrc file:
/usr/local/sbin/autologout &
The process will kick off and run in the background and after 4 minutes
give them a warning, then after one more minute it will log them off.
The weakness to doing it this way is that the user (if they are smart)
can look for the process and kill it - since the process runs as the
user. To avoid this, you would have to construct a daemon run via root
that monitored for logins.
You could easily write a script that ran once a minute or once every 10
minutes (out of cron). The script would look for logins and the time of
the login, then compare that time to the current time - if limit is
past, log them off.
Jon
_______________________________________________
RHCE at trilug.org Mailing list
http://www.trilug.org/mailman/listinfo/rhce
Archives for the RHCE list:
http://www.trilug.org/pipermail/rhce
--
Steve Holton
sholton at mindspring.com
More information about the RHCE
mailing list