lock the console after 5 minutes of inactivity.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers lock the console after 5 minutes of inactivity.
# 1  
Old 09-16-2010
lock the console after 5 minutes of inactivity.

How would i force The server console to be locked automatically after 5 minutes ?

I want it to happen for X as well as terminal session of the machine.

My Linux distribution details.
Code:
LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: OracleVMserver
Description:    Oracle VM server release 2.2.0
Release:        2.2.0
Codename:       n/a

Moderator's Comments:
Mod Comment Noticed you posted this exact same question in the LQ forums.
# 2  
Old 09-16-2010
You are talking about two different processes. "Lock" is generally referred to in a graphical user interface. For a console, we generally call this "log out".

So you should approach each problem one-at-a-time, because they are two different problems.

Which one do you want to solve first?
# 3  
Old 09-16-2010
Ok i will go with logout from the terminal in case of inactivity.
# 4  
Old 09-16-2010
The first thing that comes to mind is to use the w command to get the user id and idle time and then kill the login shell if the idle time exceeds your time limit. Sample w output:

Code:
server:~ jones$ w
13:13  up 20:10, 3 users, load averages: 1.09 1.19 1.27
USER     TTY      FROM              LOGIN@  IDLE WHAT
jones     console  -                Wed17   20:09 -
jones     p1       -                Wed20       3 -bash
jones     p2       -                Wed22       - w


This is a pretty straight forward script that you would run in the crontab file.

How about giving it a try and posting back the results and we will help you finish it.
# 5  
Old 09-16-2010
Code:
# w
 17:15:21 up 23 min,  1 user,  load average: 0.00, 0.04, 0.21
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/1    iflmud6dlcd1n.i- 17:12    0.00s  0.13s  0.01s w

This is what i got when i fired w on the terminal it seems that it will always display 0.00 second when executed for a single user. also if there are scripts running in background using crontab at interval of 3 second. does this mean system will never show idle time greater than 5 minute.

Whats the use of export TMOUT=300?(This i have got from some other forum).
# 6  
Old 09-16-2010
That is because the same user id that issued the w command is doing the check of the users. You cannot do that. You have to have a unique user id run the command from crontab.

Moderator's Comments:
Mod Comment Think! (Don't just post in forums and have others think for you!)
This User Gave Thanks to Neo For This Post:
# 7  
Old 09-16-2010
Quote:
Originally Posted by Neo
That is because the same user id that issued the w command is doing the check of the users. You cannot do that. You have to have a unique user id run the command from crontab.

Think! (Don't just post in forums and have others think for you!)
Does this mean i will have to create a separate user for running the crontab?
Also if i schedule it for every 5 minute it will again create a separate thread. Is there any inbuilt function to accomplish this?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep a log file for the last 5 minutes of contents every 5 minutes

Hi all, System Ubuntu 16.04.3 LTS i have the following log INFO 2019-02-07 15:13:31,099 module.py:700] default: "POST /join/8550614e-3e94-4fa5-9ab2-135eefa69c1b HTTP/1.0" 500 2042 INFO 2019-02-07 15:13:31,569 module.py:700] default: "POST /join/6cb9c452-dcb1-45f3-bcca-e33f5d450105... (15 Replies)
Discussion started by: charli1
15 Replies

2. UNIX for Beginners Questions & Answers

How to convert days hours minutes seconds to minutes?

Hi, please help with below time conversion to minutes. one column values: 2 minutes 16 seconds 420 msec 43 seconds 750 msec 0 days 3 hours 29 minutes 58 seconds 480 msec 11 seconds 150 msec I need output in minutes(total elapsed time in minutes) (2 Replies)
Discussion started by: ramu.badugula
2 Replies

3. Solaris

Lock password for 15 minutes

Hi, Can we configure Solaris-10 and Solaris-11, which can lock any user for 15 minutes after 5 unsuccessful logins ? I am trying to search, if it is possible but not able to find. Regards (1 Reply)
Discussion started by: solaris_1977
1 Replies

4. AIX

last - find out inactivity

I am on AIX 6.1, and need to find out who has not accessed the system within 1, 2, or 3 months depending upon the filter I specify. The output I need to have is the account name and the last time accessed: i.e. kart Mar 27 05:13 - 05:13 (00:00) Please advise. (5 Replies)
Discussion started by: Daniel Gate
5 Replies

5. UNIX for Advanced & Expert Users

Testing privileges -lock lockfile /var/lock/subsys/..- Permission denied

Hi all, I have to test some user priviliges. The goal is to be sure that an unauthorized user can't restart some modules (ssh, mysql etc...). I'm trying to automate it with a shell script but in same cases I got the syslog broadcast message. Is there any way to simply get a return code... (3 Replies)
Discussion started by: Dedalus
3 Replies

6. Red Hat

Security Question: Lock after invalid login, Session Lock and Required Minimum Password Length

Hello all, If anyone has time, I have a few questions: How do I do the following in Linux. We are using Red Hat and Oracle Enterprise Linux, which is based on Red Hat too. 1. How to lock the account after a few (like 3) invalid password attempts? 2. How do you lock a screen after 30... (1 Reply)
Discussion started by: nstarz
1 Replies

7. Programming

How to lock own console when idle?

Newbie here, have looked using search engine and can find nothing revelant to my problem.. Using Linux Here, I want to create a unix daemon (using C) that run to check user idle time, then if the idle time match the timeout, that console will be locked automatically (user need to enter... (14 Replies)
Discussion started by: develop_5889
14 Replies

8. Solaris

solaris 9 console inactivity timeout

All, I log into Solaris 9 server through a command line at the console and want enable a inactivity timer to log out of the server after 5 minutes. How can it be done? (1 Reply)
Discussion started by: bubba112557
1 Replies

9. Shell Programming and Scripting

Convert minutes to hours, minutes, seconds

How would you convert lets say a 1000 minutes to hours, minutes, seconds (1 Reply)
Discussion started by: Vozx
1 Replies

10. UNIX for Dummies Questions & Answers

how to lock keyboard without using lock command

how can I lock my keyboard while I'm away from the computer without using lock command. What other commands gives me the option to lock keyboard device? thanks (7 Replies)
Discussion started by: dianayun
7 Replies
Login or Register to Ask a Question