HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script Help
Operating System - HP-UX
1833717
Members
2445
Online
110063
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
05-17-2001 09:49 AM
05-17-2001 09:49 AM
Script Help
Hello Everyone,
I have an idea for a script and I am looking for help/suggestions and whether it is possible to do this. Is it possible to use the output of who -u to log people off if their idle time is greater than a certain value? I have an idea of how it could be done but my scripting abilities are not so great. Any help would be appreciated. Thank you so very much.
Peter
I have an idea for a script and I am looking for help/suggestions and whether it is possible to do this. Is it possible to use the output of who -u to log people off if their idle time is greater than a certain value? I have an idea of how it could be done but my scripting abilities are not so great. Any help would be appreciated. Thank you so very much.
Peter
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2001 10:10 AM
05-17-2001 10:10 AM
Re: Script Help
Hi Peter
Try this
who -u | awk '{if ($6 > "1" ) print $7 }' > /tmp/processid
for i in 'cat /tmp/processid '
do
kill -9 $i
done
This will kill the login of all user who are logged in for more than a hour , change "1" in the script for better range.
Manoj Srivastava
Try this
who -u | awk '{if ($6 > "1" ) print $7 }' > /tmp/processid
for i in 'cat /tmp/processid '
do
kill -9 $i
done
This will kill the login of all user who are logged in for more than a hour , change "1" in the script for better range.
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2001 10:32 AM
05-17-2001 10:32 AM
Re: Script Help
Hello Peter
Try this script, be careful, don?t kill your job
#!/usr/bin/ksh
#########################################################
#
# Kill Sleepers Script (Run me each half hour)
#
#########################################################
TMOUT="0:30" # Replace with time to out HH:MM
SLPRS=`who -u | awk '{ if ($6 > $TMOUT) print $7 }'`
kill -9 $SLPRS
Try this script, be careful, don?t kill your job
#!/usr/bin/ksh
#########################################################
#
# Kill Sleepers Script (Run me each half hour)
#
#########################################################
TMOUT="0:30" # Replace with time to out HH:MM
SLPRS=`who -u | awk '{ if ($6 > $TMOUT) print $7 }'`
kill -9 $SLPRS
Nobody is perfect (Nobody)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2001 05:27 PM
05-17-2001 05:27 PM
Re: Script Help
Just a note for everyone:
NEVER use kill -9
When you use kill -9 you guarentee that the processes you kill will not terminate properly. Datafiles may have incomplete records, databases can have broken chains and indexes, LAN ports will be left open and so on. Always use kill -15 for idle sessions ... but be very careful you are terminating an idle shell and not a process that may require hours to rerun. In a good script, you should test that kill -15 worked (PID is gone) and if not then resort to kill -9 but be sure to email root that you had to do this.
For truly idle shells, you can set the TMOUT env value (or autologout for csh) in /etc/profile to automatically logout the users. It is ALWAYS recommended to set root's TMOUT value, about an hour or so. There is never a reason to leave any root session idle for a long time - unless security is unimportant.
Bill Hassell, sysadmin
NEVER use kill -9
When you use kill -9 you guarentee that the processes you kill will not terminate properly. Datafiles may have incomplete records, databases can have broken chains and indexes, LAN ports will be left open and so on. Always use kill -15 for idle sessions ... but be very careful you are terminating an idle shell and not a process that may require hours to rerun. In a good script, you should test that kill -15 worked (PID is gone) and if not then resort to kill -9 but be sure to email root that you had to do this.
For truly idle shells, you can set the TMOUT env value (or autologout for csh) in /etc/profile to automatically logout the users. It is ALWAYS recommended to set root's TMOUT value, about an hour or so. There is never a reason to leave any root session idle for a long time - unless security is unimportant.
Bill Hassell, sysadmin
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP