[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] Automatic user logout script? (kill 'em all!)



Here's how I do it.  I have a script called "stop" located in /usr/bin. 
It's designed originally to "kill" a single user, but I have taken that
script and made another script that can be launched as a cron job to
"purge" the server.  First the "stop" script....

#!/bin/sh
# usage  stop username
# stop
# script to logoff a student
#

if [ $1 != "root" ]
then
   for i in $(pgrep -u $1)
   do
      kill -9 $i
   done
else
   clear
   echo "Can't kill the root!!"
fi


Now the script to "stop" them all:

#!/bin/bash
for x in `ls /home`; do
echo "Doing $x ..."
stop ${x}
done

I call this one "stop-all", made it executable (chmod a+x stop-all) and
put it into a cron job.  Works pretty slick!  :-)  YMMV



"Support list for open source software in schools." <k12osn redhat com>
writes:
>I think your "pkill $ID" needs to be "pkill -u $ID"
>
>pkill w/o options matches on process names, so you'd be trying to kill
>processes called $ID rather than owned by $ID.
>
>-- 
>Dan Young <dyoung mesd k12 or us>
>Multnomah ESD - Technology Services
>503-257-1562
>
>
>Petre Scheie wrote:
>> Yes, it should!  And here I had the gall--the gall!--to suggest to my
>> son that he check his homework before handing it in to his teacher. 
>> ;-)  Thanks Robert.
>> 
>> Petre
>> 
>> Robert Arkiletian wrote:
>>> On 12/8/06, Petre Scheie <petre maltzen net> wrote:
>>>> How about this:
>>>>
>>>> #!/bin/bash
>>>> for ID in $(awk -F: '$3 >= 500 {print $1}')
>>>
>>> shouldn't that be
>>>
>>> for ID in $(awk -F: '$3 >= 500 {print $1}' /etc/passwd)
>>>
>>>> do
>>>> pkill $ID
>>>> done
>>>>
>>>> Put this into a file, make it executable (chmod +x), and then set
>>>> root's crontab to run
>>>> it at, say 5pm.  Fedora defaults to starting user UID numbers at 500
>>>> and going up from
>>>> there, so we avoid killing any system processes.
>>>>
>>>> Petre
>>>>
>>>> Jim Anderson wrote:
>>>> > Is there a script available to automatically log out users at the
>>>> end of
>>>> > the day from K12LTSP?  I have users that tend to leave while still
>>>> > logged in.  Relatedly, is there a way to force a logout remotely
>>>> from a
>>>> > terminal prompt as root?
>>>> >
>>>> > K12LTSP v.5.0
>>>> > Dell Pentium D 2.8 GHz, 2 GB RAM
>>>> > 24 GX1 clients
>>>> >
>>>> > Jim
>>>> >
>>>> >
>>>> > _______________________________________________
>>>> > K12OSN mailing list
>>>> > K12OSN redhat com
>>>> > https://www.redhat.com/mailman/listinfo/k12osn
>>>> > For more info see <http://www.k12os.org>
>>>> >
>>>>
>>>> _______________________________________________
>>>> K12OSN mailing list
>>>> K12OSN redhat com
>>>> https://www.redhat.com/mailman/listinfo/k12osn
>>>> For more info see <http://www.k12os.org>
>>>>
>>>
>>>
>> 
>> _______________________________________________
>> K12OSN mailing list
>> K12OSN redhat com
>> https://www.redhat.com/mailman/listinfo/k12osn
>> For more info see <http://www.k12os.org>
>> 
>
>
>_______________________________________________
>K12OSN mailing list
>K12OSN redhat com
>https://www.redhat.com/mailman/listinfo/k12osn
>For more info see <http://www.k12os.org>



David N. Trask
Technology Teacher/Director
Vassalboro Community School
dtrask vcsvikings org
(207)923-3100



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]