- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- User process mode
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
01-17-2005 01:50 PM
01-17-2005 01:50 PM
set -x
for user in `who -u | awk '{ print $6":"$7 }' | grep -v "\."| awk -F : '{ print ($1*60)+$2":"$3 }'`
do
time=`echo $user | awk -F ":" '{ print $1 }'`
pid=`echo $user | awk -F ":" '{ print $2 }'`
if [[ $time -gt 180 ]]
then
kill -1 $pid 2 >> /dev/null
fi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2005 02:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2005 04:03 PM
01-17-2005 04:03 PM
Re: User process mode
I modified the script to as below , but it seems not kill any user , could suggest what is wrong ? thx
set -x
for user in `who -u | awk '{ print $6":"$7 }' | grep -v "\."| awk -F : '{ print
($1*60)+$2":"$3 }'`
do
time=`echo $user | awk -F ":" '{ print $1 }'`
pid=`echo $user | awk -F ":" '{ print $2 }'`
state=`ps -el |grep $pid | awk '{print $2}'`
if [[ $state == S ]] #compare string
then
if [[ $time -gt 180 ]]
then
kill -1 $pid 2 >> /dev/null
fi
fi
done 2>> /dev/null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2005 06:10 PM
01-17-2005 06:10 PM
Re: User process mode
you change to ps -efl (not ps -el)
HMT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2005 10:34 PM
01-17-2005 10:34 PM
Re: User process mode
set -x
for user in `who -u | awk '{ print $6":"$7 }' | grep -v "\."| awk -F : '{ print
($1*60)+$2":"$3 }'`
do
time=`echo $user | awk -F ":" '{ print $1 }'`
pid=`echo $user | awk -F ":" '{print $2}'`
state=`ps -el |grep $pid | awk '{print $2" "$4}'| grep $pid | awk '{print $1}'` #catch pid state
if [ $state=S ] #compare string
then
if [[ $time -gt 180 ]]
then
kill -1 $pid >> /dev/null
fi
fi
done
HMT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2005 02:24 AM
01-19-2005 02:24 AM
Re: User process mode
Keep in mind that you are looking only at a snapshot of the process table when you do a 'ps'. All process sleep while waiting for their CPU time-slice, so the chances of your script finding a user's sleeping process is quite high. But since you are also defining the idle time limit at 180 minutes, the state of the process is somewhat of a moot point.
Just my 2cts worth,
Mark