[comp.unix.aix] Is there a way to logout an inactive user after nn minutes?

fredrick@acd.acd.ucar.edu (Tim Fredrick) (05/14/91)

Re: AIX3.1.5, is there a way to logout an inactive user after nn minutes of
inactivity?  This would help us to manage a situation where a terminal is
shut off (via a network switch) but the user stays logged on.  Is there a
PD utility to accomplish this?  Thanks.  --Tim

mjrx@ellis.uchicago.edu (Marty Ryan) (05/14/91)

In article <11395@ncar.ucar.edu> fredrick@acd.acd.ucar.edu (Tim Fredrick) writes:
>Re: AIX3.1.5, is there a way to logout an inactive user after nn minutes of
>inactivity?  This would help us to manage a situation where a terminal is
>shut off (via a network switch) but the user stays logged on.  Is there a
>PD utility to accomplish this?  Thanks.  --Tim
>

In the ksh, there is an environment variable, TMOUT, which specifies the
number of minutes the shell will wait inactive before exiting. If you
were to set this in /etc/profile, all ksh users would be handled. I don't
know if the csh has a similar construct.

elee4fg@jetson.uh.edu (05/14/91)

In article <11395@ncar.ucar.edu>, fredrick@acd.acd.ucar.edu (Tim Fredrick) writes:
> Re: AIX3.1.5, is there a way to logout an inactive user after nn minutes of
> inactivity?  This would help us to manage a situation where a terminal is
> shut off (via a network switch) but the user stays logged on.  Is there a
> PD utility to accomplish this?  Thanks.  --Tim
>
I wrote something to do that.  As far as I know it works fine on my system.
Try it at your risk if your want.
Fax me your fax number and name and I will fax you the programs.
Seng C. Gan
Fax:(713)874-7874
 

wargaski@casbah.acns.nwu.edu (Robert E. Wargaski Jr.) (05/15/91)

mjrx@ellis.uchicago.edu (Marty Ryan) writes:
|> 
|> In the ksh, there is an environment variable, TMOUT, which specifies the
|> number of minutes the shell will wait inactive before exiting. If you
|> were to set this in /etc/profile, all ksh users would be handled. I don't
|> know if the csh has a similar construct.

It does.  Setting autologout variable will cause the shell to log
itself out after a certain period of idle time.  For example,

		set autologout=30

will log you out after thirty minutes of idle time.

Rob

-- 

Rob Wargaski
r-wargaski@nwu.edu			Colby is good.
ACNS DSS, Northwestern University

fredrick@acd.uucp (Tim Fredrick) (05/16/91)

>> In the ksh, there is an environment variable, TMOUT, which specifies the
>> number of minutes the shell will wait inactive before exiting. If you
>> were to set this in /etc/profile, all ksh users would be handled. I don't
>> know if the csh has a similar construct.
>
>It does.  Setting autologout variable will cause the shell to log
>itself out after a certain period of idle time.  For example,
>
>		set autologout=30
                                                                             
I tried putting this in my own .cshrc file and I didn't get logged out after
30 minutes of inactivity.  Is there some other file that this command goes
into?  Is there some daemon that needs to be running?
                                                                             
And a more general question -- is there a file that will set up environment
variables and/or aliases for any user logging in?

Thanks                                                                       
-Tim Fredrick                                                                  
                                                                               
                                                                             
                                                                               

mrl@uai.com (Mark R. Ludwig) (05/17/91)

In article <1991May14.213500.6113@casbah.acns.nwu.edu>, wargaski@casbah (Robert E. Wargaski Jr.) writes:
>
>		set autologout=30
>
>will log you out after thirty minutes of idle time.

It doesn't seem to work on our (3003) system.  I wish it did.$$
-- 
INET: mrl@uai.com       UUCP: uunet!uaisun4!mrl       PSTN: +1 213 822 4422
USPS: 7740 West Manchester Boulevard, Suite 208, Playa del Rey, CA  90293
WANT: Succinct, insightful statement to occupy this space.  Inquire within.

rbraun@spdcc.COM (Rich Braun) (05/18/91)

fredrick@acd.uucp (Tim Fredrick) writes:
>>> In the ksh, there is an environment variable, TMOUT, ...
>I tried putting this in my own .cshrc file and I didn't get logged out ...

You've answered your own question:  if you're running csh, you don't
get this feature.  If you're running ksh, your .cshrc file won't be read.
Switch to ksh, in any event; it's a much better shell.  It uses
.profile for startup purposes.

>And a more general question -- is there a file that will set up environment
>variables and/or aliases for any user logging in?

Yes.  For csh, it's /etc/cshrc; for ksh, it's /etc/profile.  The problem
with doing things this way is that users can't bypass commands in these
files, so only put >absolutely mandatory< stuff in the system-wide
startup files, to avoid creating some of the monster 2-minute logins
I've run across in some workplaces.  Put optional stuff in an separate
file, which users can run by putting the line

	ENV=/usr/local/lib/local-goodies.sh ; export ENV

into their own .profile script.

A question for those whose AIX and ksh knowledge surpasses my own:
is there a way for a sub-shell to export environment variables to its
parent, and/or is there a way to cause ksh to run a script in its
own context rather than within a subshell?  (This is addressed via
the 'source' command in csh, but I know of no equivalent in ksh.)
For example, if I create a file called "setup" which contains the
statements

	alias -x cmd=abc
	VAR=def ; export VAR

I'd like to be able to run this script and have it permanently affect
my login session, the way it would affect my session if installed in
.profile.

-rich

robin@pensoft.uucp (Robin Wilson) (05/21/91)

In article <7548@spdcc.SPDCC.COM> rbraun@spdcc.COM (Rich Braun) writes:
>Switch to ksh, in any event; it's a much better shell.  It uses
>.profile for startup purposes.

Actually, both "sh" and "ksh" use the ".profile" for startup purposes.  So
it is not really a good idea to use "ksh" specific commands (ie. ones not 
found in "sh") in this file.  Instead I usually specify "ENV=$HOME/.kshrc" 
and then "export ENV" (note that the command syntax "export ENV='blah'" 
doesn't work in "sh", so this will cause you problems if you use it in your
".profile").

Why is this significant?  Because "cron" uses "/bin/sh" as it's default shell.
If you have "/bin/ksh" linked to "/bin/sh" this is not a problem; however you
probably don't want to do this so that you will always have a bourne shell
available.  

Beyond this, cron (yes it is a bug) on the RS6K reads the user's .profile 
at every command.  If your ".profile" has some kind of request for input, 
or just output it will mess up cron (output will show up as a mail message
with the subject: "The following is output from one of your cron commands"
(or something like that) -- if you have several cron jobs going each day, 
you will be inundated with meaningless mail).

Usually I try to setup "bourne shell" environments that don't require 
human intervention and don't have any output in the ".profile" file; while
at the same time using the shell ENV variable to specify the environment for
my interactive shells.


BTW, the original question was about "TIMEOUT" variables for the shell.
Here they are:

/bin/sh  ==  TIMEOUT
/bin/ksh ==  TMOUT
/bin/csh ==  timeout (I'm not sure of this one, I have never found a use for 
                      c shell... :-) )

Use whatever command is neccessary to set an environment variable for each of 
these.  On both "ksh" and "sh" there is an environment "setting" tool called
"readonly" which is used in place of "export".  You would set the TMOUT and/or
TIMEOUT variables like so:

TIMEOUT=600 # shell timeout in seconds
TMOUT=600   # ksh timeout in seconds

readonly TIMEOUT TMOUT

This would be added to the "/etc/profile" file, and then the users would not 
be able to "unset" these values on their own.

>A question for those whose AIX and ksh knowledge surpasses my own:
>is there a way for a sub-shell to export environment variables to its
>parent, and/or is there a way to cause ksh to run a script in its
>own context rather than within a subshell?  (This is addressed via
>the 'source' command in csh, but I know of no equivalent in ksh.)
>For example, if I create a file called "setup" which contains the
>statements

The ksh/sh equivalent of "source" from csh is "exec" or just plain ".".
For example, typing:

. $HOME/.profile 

will re-execute your ".profile" and modify (if neccessary) your existing 
environment.  So for a shell script that you always want to modify your 
current shell environment, you would use the following alias:

alias script='. <path>/script'


NOTE: this only works in "ksh" since "alias" is not a command that "sh" 
recognizes.


+-----------------------------------------------------------------------------+
|The views expressed herein, are the sole responsibility of the typist at hand|
+-----------------------------------------------------------------------------+
|UUCP:     pensoft!robin                                                      |
|USNail:   701 Canyon Bend Dr.                                                |
|          Pflugerville, TX  78660                                            |
|          Home: (512)251-6889      Work: (512)343-1111                       |
+-----------------------------------------------------------------------------+

moody@snap.austin.ibm.com (05/21/91)

In article <1991May20.221557.9652@pensoft.uucp> robin@pensoft.uucp (Robin Wilson) writes:

[stuff deleted]

>Beyond this, cron (yes it is a bug) on the RS6K reads the user's .profile 
>at every command.

Robin, this bug has been fixed for some time now....

-- 
James Moody				aixnet:moody@moody.austin.ibm.com
Personal Systems Programming Austin	VNET:MOODY@AUSVMQ
AIX Field Support - Level 3		internet:moody@aixwiz.austin.ibm.com

ghe@physics.orst.edu (Guangliang He) (05/22/91)

In article <7781@awdprime.UUCP>, moody@snap.austin.ibm.com writes:
|> In article <1991May20.221557.9652@pensoft.uucp> robin@pensoft.uucp (Robin Wilson) writes:
|> 
|> [stuff deleted]
|> 
|> >Beyond this, cron (yes it is a bug) on the RS6K reads the user's .profile 
|> >at every command.
|> 
|> Robin, this bug has been fixed for some time now....
|> 
|> -- 
|> James Moody				aixnet:moody@moody.austin.ibm.com
|> Personal Systems Programming Austin	VNET:MOODY@AUSVMQ
|> AIX Field Support - Level 3		internet:moody@aixwiz.austin.ibm.com

Really, what is the newest version number? We are still living 3003 age now.
Should we receive these bug fixs free as soon as it available or we have to 
ask for it? :-(.

---
  Guangliang He                |  -----Go Blazers!-----
  ghe@physics.orst.edu         |  -----Go Blazers!-----