Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CMS Script to logoff users that have been logged in for 24hrs or more.

Status
Not open for further replies.

aphophas

IS-IT--Management
Oct 21, 2004
3
US
I noticed that in post "thread690-1359647", users were looking for a script to kick users off of the CMS after a certain length of time. I have something that I use, and it works great.

***************
#!/usr/bin/ksh

ps -ef | grep /cms/bin/chipr | egrep 'Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec' | awk '$1> 60 {print $1" "$3}' | \
while read -r NAME PID
do

if [ "$NAME" = "someuser" ] || [ "$NAME" = "someuser" ]
then
echo "protected user" >/dev/null
else


kill -KILL $PID

fi
done
***************

Since this looks at the chipr, the return will only bring back folks in the system that are connected to CenterVue. Any user that has logged in within 24 hours, will have a time stamp instead of a "Nov 5 00:00" entry. So the egrep grabs only those users not logged in the day the script is ran.

This also protects root, console, etc.users, from being included, like in a"who -uH" command.

You can replace the "kill -KILL" command with "echo", and you can see the PIDS that will be killed painted to the screen.

Thanks,
Johnny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top