- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- controlling terminal sessions
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 07:54 AM
10-03-2001 07:54 AM
Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 08:03 AM
10-03-2001 08:03 AM
Re: controlling terminal sessions
You don't need to write a script, there is a shell variable for this called TMOUT
Set TMOUT=60 in your .profile and your session will be killed after an inactivity of 60 minutes.
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 08:15 AM
10-03-2001 08:15 AM
Re: controlling terminal sessions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 08:24 AM
10-03-2001 08:24 AM
Re: controlling terminal sessions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 08:29 AM
10-03-2001 08:29 AM
Re: controlling terminal sessions
You can see the idle time of a terminal session by looking at the sixth field from:
# who -u
This will show the time or the word "old" if the idle time is greater than 24-hours. Since the 'pid' is available as the seventh field, you could use this to kill session.
Remember that if you choose to kill the session, there could be associated processes running that will be killed. If this is still your choice, *at least* kill the session with a hangup ('kill -1 pid') and *not* a 'kill -9' which cannot be trapped to give any process a chance to cleanup files and/or shared memory. A simple kill of the session pid will not suffice.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 08:40 AM
10-03-2001 08:40 AM
Re: controlling terminal sessions
Setting parameter TMOUT=300 in /etc/profile will terminate only the idle shell (ksh & sh) after 300 seconds.
Make it readonly (readonly TMOUT) in /etc/profile , so that nobody overrides it.
Thanks.
Prashant.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 08:50 AM
10-03-2001 08:50 AM
Re: controlling terminal sessions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 10:14 AM
10-03-2001 10:14 AM
Re: controlling terminal sessions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 10:54 AM
10-03-2001 10:54 AM
Re: controlling terminal sessions
Sounds like you want to kill all processes that have a controlling tty and have been running for at least an hour. ps -ef will show you the start time and controlling tty for processes. Your script would have to do the math to determine the elapsed time (I believe Perl would be helpful), verify you had a controlling tty, and verify you weren't killing a process you didn't really need to be killing.
That's rather scary. A rogue script of this nature can cause much damage. The chances for shooting yourself in the foot are pretty good. I believe you'd be much better off using TMOUT.
You might check with the application to see if there's a control in it for terminating inactive sessions. Perhaps the better approach is the most difficult choice: educate your users as to why they need to exit after performing their queries. Obviously that's of political nature and you probably need the right manager on the issue.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2001 11:32 AM
10-03-2001 11:32 AM
Re: controlling terminal sessions
One more suggestion: You should consider driving your script by looking for processes returned by 'ps' that have a 'uid' greater than 100 (for example); that have a controlling 'tty'; *and* have been inherited by 'init' (ppid=1).
The object is that you are then looking for "safe" (not-root;not daemon) processes that represent things like telnet sessions that have been adopted by 'init' due to abnormal termination (like a network disconnection).
Consider, too, using the UNIX95 (XPG4) option of 'ps' to return the TIME column format as "[dd-]hh:mm:ss" instead of "mmmm:ss". This may make your analysis easier.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2001 11:45 AM
10-05-2001 11:45 AM
SolutionLet me give this a thought here too...very similar to Jim's.
When you run who -u see what you can grep for to gather only these tty sessions. Example for our dial ups they always appear as wc_x_ _ _ so I would do a who -u | grep wc_x. I agree with Jim to use that idle time. So maybe a script that is something like:
who -u | grep wc_x > your who.outputfile
awk ' BEGIN {
while ( "cat who.outputfile" | getline ) {
entries++
if ( $6 > "2:00" )
print $1, $7 }
} '
Now this will display the user and the pid...and all you would have to do is ensure that is what you want BEFORE you change the script to run a kill for $7 instead of a print...I'd recommend a graceful kill not a silver (-9) bullet.
Just a thought, I'm no programmer !
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2001 12:11 PM
10-05-2001 12:11 PM
Re: controlling terminal sessions
YOU GO GIRL!!!