The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
kill idle users efrenba HP-UX 13 03-31-2008 11:38 PM
Script allows user to kill other users: I'd like to know HOW... alexop AIX 8 07-10-2007 05:41 PM
script for killing idle users jdel80 Shell Programming and Scripting 7 12-19-2005 04:42 PM
Is there a script available to kill Idle users rfmurphy_6 HP-UX 5 06-16-2005 05:31 PM
Script to kill stranded/orphan process by users. rjohnson Shell Programming and Scripting 4 03-07-2002 10:37 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-24-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
script to kill idle users

Hi,
My aim is to write a script to kill users who are idle more than 30 minutes. I wrote follwoing script, getting help from one of the scripts available in these forums:


Code:
#!/bin/sh

who -u | awk '{print $1,$6,$7}' > user.txt


grep ":3" /tayyab/user.txt > /tayyab/idle_u.txt
grep ":4" /tayyab/user.txt >> /tayyab/idle_u.txt
grep ":5" /tayyab/user.txt >> /tayyab/idle_u.txt
grep ":6" /tayyab/user.txt >> /tayyab/idle_u.txt
grep "1:" /tayyab/user.txt >> /tayyab/idle_u.txt
grep "2:" /tayyab/user.txt >> /tayyab/idle_u.txt
grep "3:" /tayyab/user.txt >> /tayyab/idle_u.txt
grep "4:" /tayyab/user.txt >> /tayyab/idle_u.txt
grep "5:" /tayyab/user.txt >> /tayyab/idle_u.txt

echo "IDLE Users"
echo "-------------------"
cat /tayyab/idle_u.txt

It gives me the list of users idle more than 30 minutes and less than 6 hours, but I dont know how to use kill command to kill the users listed here. As well as, if any body can correct the above code to make it more short, it'll be a great favor.

Regards,
Tayyab
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0