1834457 Members
2635 Online
110067 Solutions
New Discussion

Re: Idle process

 
SOLVED
Go to solution
juno2
Super Advisor

Idle process

how to force the user logout when the uesr has idle for a certain of time ( eg. 3 hrs) ? thx.
20 REPLIES 20
James Murtagh
Honored Contributor
Solution

Re: Idle process

Hi,

If they are accessing the shell you would normally do this by setting the global shell variable TMOUT in /etc/profile and making it read only. If this doesn't apply to specific users change this in their .profile.

Regards,

James.
Michael Tully
Honored Contributor

Re: Idle process

Hi,

There is a built-in shell variable called 'TMOUT' for ksh/posix. This value can be set in either ther /etc/profile file or the users own .profile.

If your using 'csh' you can use the variable called 'autologout'.
Consult the 'sh-posix' and 'csh' man pages for further details.

Regards
Michael
Anyone for a Mutiny ?
Michael Steele_2
Honored Contributor

Re: Idle process

From /home/usr/.profile add:
export TMOUT=3600

3600 = 1 hour
1800 = 30 minutes
900 = 15 minutes
600 = 10 minutes
60 = 1 minute

A warning message will be displayed to every terminal that the connection will be logged out in 60 seconds hit any key to remain logged in.

You can also put it into /etc/profile.
Support Fatherhood - Stop Family Law
T G Manikandan
Honored Contributor

Re: Idle process

For user with ksh and posix shell you can use the parameter TMOUT.

TMOUT=600(time in sec)
export TMOUT

You can set this in the global file /etc/profile so that I reflects for all users.

For csh you can use
autologout=60(in min)

THe global file here is /etc/csh.login


THanks
juno2
Super Advisor

Re: Idle process

i add it to my profile , but when i login , then :

bash: TMOUT: command not found
how to solve ? thx
juno2
Super Advisor

Re: Idle process

But if the login will not access to the shell , it only access our Oracle database , how to kill the idle process ? thx.
juno2
Super Advisor

Re: Idle process

HI Michael Tully ,

If add it to /etc/profile ,then the system user (eg. root , bin ) will also logout when it is timeout , is there other suggest to prevent the system user will not logout? thx
malay boy
Trusted Contributor

Re: Idle process

Hi,
well for oracle,in order for autologoff, you need to create a profile and assign the profile to all user.Example:

1) CREATE PROFILE test_profile LIMIT
IDLE_TIME 60;

Next assign test_profile to user.
what this do is , logoff the user if it session idle more than 60 minutes.
(I get this from Oracle 9 book don't know whether it support version less than this).
There are three person in my team-Me ,myself and I.
Yogeeraj_1
Honored Contributor

Re: Idle process

hi,

At the Oracle level, use profiles. The session will be killed (status killed in v$session) and all resources released. The session will still appear in v$session but will not consume any resources (locks and such).

I have the following profile for my users:
CREATE PROFILE USERPROFILE1 LIMIT
SESSIONS_PER_USER 4
CPU_PER_SESSION DEFAULT
CPU_PER_CALL DEFAULT
CONNECT_TIME DEFAULT
IDLE_TIME 600
LOGICAL_READS_PER_SESSION DEFAULT
LOGICAL_READS_PER_CALL DEFAULT
COMPOSITE_LIMIT DEFAULT
PRIVATE_SGA DEFAULT
FAILED_LOGIN_ATTEMPTS DEFAULT
PASSWORD_LIFE_TIME 30
PASSWORD_REUSE_TIME 90
PASSWORD_REUSE_MAX DEFAULT
PASSWORD_LOCK_TIME DEFAULT
PASSWORD_GRACE_TIME DEFAULT
PASSWORD_VERIFY_FUNCTION DEFAULT;

Our NEW users are created with the following command:
create user yd01
identified by y23234b2
default tablespace tbs_lmt_users
temporary tablespace temp
profile userprofile1
password expire;

or if you want to modify a user profile, you can use:
alter user yd01 profile userprofile1;


NB. Unfortunately, at the OS level, your unix session will still remain active. So don't forget to modify your /etc/profile to include: export TMOUT=600

hth
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Yogeeraj_1
Honored Contributor

Re: Idle process

hi again,

for bash & korn shells, include the following in /etc/profile

readonly TMOUT=10800
export TMOUT

I set it as readonly to avoid users trying to change it's value, including root.

regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Michael Tully
Honored Contributor

Re: Idle process

Why not have root logout? In fact the 'root' account shouldn't be used unless your using the console ... directly.

The TMOUT can be a good thing or a bad thing depending on the requirements.
1) it forces people to log out if idle.
2) logs out unattended terminals/sessions (people gone home)

The best alternative is to have a skeleton .profile (/etc/skel.profile) that contains the TMOUT value. Each new user that gets created, will have the variable included. You would of course need to add the string to existing users .profile file.

Regards
Michael
Anyone for a Mutiny ?
juno2
Super Advisor

Re: Idle process

I tried autologout and TMOUT , but it is not successful cos the user will not go to the UNIX shell - when the user login , the user will go to the db ( they will not stay at the shell) , how to logout the user in my case.
juno2
Super Advisor

Re: Idle process

I tried TMOUT , it is OK if the user "stay' at the shell , but how about if the login will automatically go to the database ? thx in advance.
juno2
Super Advisor

Re: Idle process

may i clearly state my wish , in our case ,the users can't go to the shell , when they are login , they will directly go to the database , I tried to add TMOUT and autologout to the user profile , it can't logout the user , ( for the user if they stay at the shell is OK ) , can suggest how to solve it ? thx.
Michael Tully
Honored Contributor

Re: Idle process

Hi Juno,

I think for us to help more, please advise:

The actual process of connection to your database.
i.e. telnet to server
Each user runs a command from a menu to access your database?
What database is it? oracle, informix?

Regards
Michael
Anyone for a Mutiny ?
juno2
Super Advisor

Re: Idle process

Hi Michael ,
We have Oracle database, for the security reason , when the user use telnet to login , the system will force the login to access to the oracle database directly ( so i said they will not access at the unix shell) , can suggest how to solve it? thx
Bill Hassell
Honored Contributor

Re: Idle process

There is nothing in HP-UX that will force an application to terminate because a user is not actively using the program. Simply put, it would be dangerous to terminate a database application from the outside. Instead, your Oracle application would have to be modified to detect inactivity and terminate in an appropriate manner.


Bill Hassell, sysadmin
juno2
Super Advisor

Re: Idle process

cos I can see the login on the shell by the command "who -u username" , so I am wonder whether it can be terminated by any UNIX function ? thx.
Yogeeraj_1
Honored Contributor

Re: Idle process

hi,

the following, as in the example below, will do it:

K250: home/yd>who -u|grep yd
yd ttyqf Apr 16 07:34 . 15781 c332
K250: home/yd>kill -15 15781

hth
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
T G Manikandan
Honored Contributor

Re: Idle process

Why dont you close the idle sessions on the application sidei.e oracle

you have a parameter

sqlnet.expire_time.

By placing this in the sqlnet.ora file like

sqlnet.expire_time=10

close the 10 min idle sessions.

revert on the same