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

Re: [K12OSN] Users not logging off causing server to max out.



Neat script.  Am I mistaken or do you have to run this script after the
date changes on your system.  For example, running it at 23:00 (11PM)
system time Tuesday will delete only the processes that have a date of
Monday or earlier because these will be in the Month-Day format.

Darryl

Julius Szelagiewicz said:
> Pat,
> 	no command line, but a script below will do it for you. run it
> nightly. details on how in "man crontab". julius
>
> #!/bin/bash
> #kill old leftover processes  - all of them
>
> users=$(awk -F":" '{if ( $3 >= 500 ) print $1}' /etc/passwd | grep -v -e
> smb -e ^nfs )
> for user in $users
> do
> #echo $user
>
>         processes=$(ps -ef | grep ^"$user " | grep -e Jan[0-9] -e Feb[0-9]
> -e Mar[0-9] -e Apr[0-9] -e May[0-9] -e Jun[0-9] -e Jul[0-9] -e Aug[0-9] -e
> Sep[0-9] -e Oct[0-9] -e Nov[0-9] -e Dec[0-9] |awk '{print $2}')
>
>         for process in $processes
>         do
>                 kill -9 $process
>         done
>
> done




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