Sponsored Content
Full Discussion: Removing Inactive Sessions
Top Forums Shell Programming and Scripting Removing Inactive Sessions Post 302505140 by stuaz on Wednesday 16th of March 2011 10:46:37 AM
Old 03-16-2011
Removing Inactive Sessions

Hi,

I have the following script:
Code:
 
 
# Inactive Users Removed
#
# Created by: stuaz
# Created on: 16/03/11
#
# This script runs from the Cron
####################################
# Variables
email=blah@blah.com
log=/utils/sdennis/inactiveusers.log
#
# Command to find inactive users and there process numbers
my=`/usr/bin/who -u|/usr/bin/grep -v nppp|/usr/bin/awk '{ if($6>"1:00") print($7
)}'`
# Command to list users in Email
my2=`/usr/bin/who -u|/usr/bin/grep -v nppp|/usr/bin/awk '{ if($6>"1:00") print (
"Username: " $1 " " "Inactive for: " $6)}'`
echo $my
# Send list of inactive users to log file.
echo $my2 > $log
# Email log file
cat $log | mail -s "Inactive Users Removed from the System" $email
# Run deleteuser command to remove inactive users
if [ "$my" ]
then
/u/ud/bin/deleteuser $my >/dev/null 2>&1
fi

All it does is check the "who" for people who have been inactive for the past hour and then emails that list to me. Then with that list it runs the "deleteuser" command which will gracefully log them off.

The problem I have is while this script will work if it finds one user, it will fail and do nothing if it encounters multiple people.

How can I modify this to accept that there may be multiple people who are inactive for an hour and remove them?

Thanks,
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to logout inactive users????

I would like to automatically logout from the system inactive users depending on their functions. For example there are users that I would like to logout after 15 minutes of inactivity, but there are others that I would like to logout after 30 minutes of inactivity. It's possible to do this??? (6 Replies)
Discussion started by: rrivas
6 Replies

2. Programming

wired and inactive pages

Hello How to find out wired pages and inactive pages in HP -UNIX. Bye (1 Reply)
Discussion started by: manjunath
1 Replies

3. UNIX for Advanced & Expert Users

inactive pages

hi, plz tell me, how can get the inactive pages in HP UX. bye.... (1 Reply)
Discussion started by: venkat_t
1 Replies

4. UNIX for Dummies Questions & Answers

Inactive Session

Hi, I am new to forum, I am wondering anyone can help me ? Is there a command to tell whether a particular process is already inactive, so I can issue a kill command to end it. I have been encountering scenerio whereby users always shutdown abnormally by closing the windows, and my application... (12 Replies)
Discussion started by: lowtaiwah
12 Replies

5. Shell Programming and Scripting

Getting error while getting status of active and inactive sessions from ORACLE DB

Hi All, I have a written a test script which retrieves the status of active and inactive sessions from oracle DB, but i am receiving error while executing. My script is filepath="/home/ocsg/scripts/db_session_report/current_session_report.txt"... (1 Reply)
Discussion started by: poweroflinux
1 Replies

6. UNIX for Advanced & Expert Users

Find Inactive VG

lsvg -o shows active VGs. Is there a way to find inactive VGs with a command? Please advise. (2 Replies)
Discussion started by: Daniel Gate
2 Replies

7. UNIX for Advanced & Expert Users

Help in Oracle Inactive Sessions

hi , i could see 50-60 oracle inactive session running under my application name, does this cause any issue.. or can this inactive session be excluded , if so how can we reduce them or exclude them , your inputs are much required. my application runs on C++ with oracle , pro*c involved.... (1 Reply)
Discussion started by: senkerth
1 Replies
Class::MethodMaker::hash(3pm)				User Contributed Perl Documentation			     Class::MethodMaker::hash(3pm)

NAME
Class::Method::hash - Create methods for handling a hash value. SYNOPSIS
use Class::MethodMaker [ hash => [qw/ x /] ]; $instance->x; # empty $instance->x(a => 1, b => 2, c => 3); $instance->x_count == 3; # true $instance->x = (b => 5, d => 8); # Note this *replaces* the hash, # not adds to it $instance->x_index('b') == 5; # true $instance->x_exists('c'); # false $instance->x_exists('d'); # true DESCRIPTION
Creates methods to handle hash values in an object. For a component named "x", by default creates methods "x", "x_reset", "x_clear", "x_isset", "x_count", "x_index", "x_keys", "x_values", "x_each", "x_exists", "x_delete", "x_set", "x_get". Methods available are: "*" Created by default. This method returns the list of keys and values stored in the slot (they are returned pairwise, i.e., key, value, key, value; as with perl hashes, no order of keys is guaranteed). If any arguments are provided to this method, they replace the current hash contents. In an array context it returns the keys, values as an array and in a scalar context as a hash-reference. Note that this reference is no longer a direct reference to the storage, in contrast to Class::MethodMaker v1. This is to protect encapsulation. See x_ref if you need that functionality (and are prepared to take the associated risk.) If a single argument is provided that is an arrayref or hashref, it is expanded and its contents used in place of the existing contents. This is a more efficient passing mechanism for large numbers of values. *_reset Created by default. Called without an argument, this resets the component as a whole; deleting any associated storage, and returning the component to its default state. Normally, this means that *_isset will return false, and * will return undef. If "-default" is in effect, then the component will be set to the default value, and *_isset will return true. If "-default_ctor" is in effect, then the default subr will be invoked, and its return value used to set the value of the component, and *_isset will return true. If called with arguments, these arguments are treated as indexes into the component, and the individual elements thus referenced are reset (their storage deleted, so that *_isset(n) will return false for appropriate n, except where "-default" or "-default_ctor" are in force, as above). As with perl arrays, resetting the highest set value implicitly decreases the count (but x_reset(n) never unsets the aggregate itself, even if all the elements are not set). *_clear Created by default. Empty the component of all elements, but without deleting the storage itself. If given a list of keys, then the elements that exist indexed by those keys are set to undef (but not deleted). Note the very different semantics: "$x->a_clear('b')" sets the value of "b" in component 'a' to undef (if "b") already exists (so "$x->a_isset('b'))" returns true), but "$x->a_clear()" deletes the element "b" from component 'a' (so "$x->a_isset('b'))" returns false). *_isset Created by default. Whether the component is currently set. This is different from being defined; initially, the component is not set (and if read, will return undef); it can be set to undef (which is a set value, which also returns undef). Having been set, the only way to unset the component is with *_reset. If a default value is in effect, then *_isset will always return true. *_isset() tests the component as a whole. *_isset(a) tests the element indexed by a. *_isset(a,b) tests the elements indexed by a, b, and returns the logical conjunction (and) of the tests. *_count Created by default. Returns the number of elements in this component. This is not affected by presence (or lack) of a "default" (or "default_ctor"). Returns "undef" if whole component not set (as per *_isset). *_index Created by default. Takes a list of indices, returns a list of the corresponding values. If a default (or a default ctor) is in force, then a lookup by index will vivify & set to the default the respective elements (and therefore the aggregate data-structure also, if it's not already). *_keys Created by default. The known keys, as a list in list context, as an arrayref in scalar context. If you're expecting a count of the keys in scalar context, see *_count. *_values Created by default. The known values, as a list in list context, as an arrayref in scalar context. *_each Created by default. The next pair of key, value (as a list) from the hash. *_exists Created by default. Takes any number of arguments, considers each as a key, and determines whether the key exists in the has. Returns the logical conjunction (and). *_delete Created by default. This operates exactly like *_reset, except that calling this with no args does nothing. This is provided for orthogonality with the Perl "delete" operator, while *_reset is provided for orthogonality with other component types. *_set %n = $x->h; # (a=>1,b=>2,c=>3) (in some order) $h->h_set(b=>4,d=>7); %n = $h->a; # (a=>1,b=>4,c=>3,d=>7) (in some order) Created by default. Takes a list, treated as pairs of index => value; each given index is set to the corresponding value. No return. If two arguments are given, of which the first is an arrayref, then it is treated as a list of indices of which the second argument (which must also be an arrayref) are the corresponding values. Thus the following two commands are equivalent: $x->a_set(b=>4,d=>7); $x->a_set(['b','d'],[4,7]); *_get Created by default. Retrieves the value of the component without setting (ignores any arguments passed). perl v5.14.2 2011-11-15 Class::MethodMaker::hash(3pm)
All times are GMT -4. The time now is 07:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy